__gshared const TEST = import(`onlineapp.d`);
extern(C) void main(){
__gshared bin_ptr = TEST.ptr;
}
试试这个:
__gshared bin_ptr;
shared static this()
{//放在这个里面?
bin_ptr = TEST.ptr;//但这个是全局的了
}
__gshared const TEST = import(`onlineapp.d`);
extern(C) void main()
{
}
有-betterC
,得用pragma(crt_constructor)
.
这样:
__gshared immutable(char)* bin_ptr;
pragma(crt_constructor)
void init_ptr()
{//pragma
bin_ptr = TEST.ptr;
}
__gshared TEST = import("this.d");
extern(C) void main()
{
}