好吧,基本上,这就是我想要做的......
我有一个 D 函数,例如:
extern (C) {
void someFunc(string s) {
writeln("Got : " ~ s);
}
}
我想从 C 代码中使用 char*
参数调用它。
这怎么可能?
最佳答案
好的,刚刚找到了答案(如何调用没有问题,但我如何将 char *
转换为 D 兼容的 string
):
extern (C) {
void myfunc(char* s) {
writeln(to!string(s));
}
}
关于使用字符串参数从 C 调用 D 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23010655/