betterC版的前后
import core.stdc.stdio;
struct Foo{
ubyte bar;
}
__gshared Foo foo;
void* baz = &foo;
void* bar;
extern(C):
pragma(crt_constructor)
void initialize() { bar = &foo.bar; }
//在初化c运行时后,d运行时前,运行
void main()
{
*(cast(ubyte*)bar) = 10;
printf("%d", foo.bar);
}