how to call std_stdio_static_this from a dynamically loaded shared library (osx)
timotheecour
thelastmammoth at gmail.com
Wed Oct 3 11:23:29 PDT 2012
> Module constructors if one of the things that don't work
> properly. I don't know exactly how this works in std.stdio I
> would need to study the code. If I recall correctly std.stdio
> uses some kind of hack to avoid circular dependencies that can
> otherwise occur if two modules, both having module
> constructors, import each other.
Yes, that hack consists in :
1) defining extern(C) void std_stdio_static_this() instead of
static this()
2) defining an auxiliary module std.stdiobase who will call it at
module construction:
module std.stdiobase;
extern(C) void std_stdio_static_this();
shared static this(){
std_stdio_static_this();
}
I'm still puzzled as to why modifying the code inside
std_stdio_static_this (say with assert(0)) doesn't have any
effect (hence the need for the templated version I'm using).
Another workaround (besides adding std_stdio_static_this2) would
be to make the field File.p non-private so that my
std_stdio_static_this2 could be defined outside std.stdio. Any
suggestion?
More information about the Digitalmars-d-learn
mailing list