如何在D中将结构转换为C指针?

时间:2013-12-16 20:29:08

标签: c pointers structure d

如何在D中将D结构转换为C指针?类似的东西:

struct test {}
void main() {
    auto testv = test();
    randomfunction(cast(cPtr) test);
}

1 个答案:

答案 0 :(得分:6)

如果您只想将结构的地址传递给函数,请使用&(address-of)运算符来获取指向结构变量的指针:

randomFunction(&testv);