Caller:
import core.stdcpp.string;
//用C++的串.
import std.stdio;
extern(C){
bool bb(ref string a);
}
bool cc(ref string a);
void main()
{
string c="bb";
string d="";
writeln(c,d);
bool a=cc(c);
writeln(c,d);
bool b=bb(d);
writeln(a,b);
}
C++
Here, add packaging as needed:
//放在a.cpp中.并单独构建生成a.obj.
外 "C" 极 bb(串&a){
中 小一(a);
}
外 "C" 极 _D1n2ccFKAyaZb(串&a){
中 小一(a);
}
Then link together:
dmd -i n.d
link n.obj a.obj legacy_stdio_definitions.lib
n.exe
//legacy_stdio_definitions里面有printf,scanf