0
点赞
收藏
分享

微信扫一扫

d不能用非常ctfe指针


__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()
{
}


举报

相关推荐

0 条评论