You can go from line D with zero completion with std.string.toStringz. In the same way there is std.string.fromStringz:
extern (C++) immutable(char)* dfunc(const char* s) {
import std.string;
return toStringz(fromStringz(s) ~ "response");
}
And then the caller in C ++
#import <Cocoa/Cocoa.h>
char *dfunc(const char *);
extern "C" int rt_init();
extern "C" int rt_term();
int main(int argc, const char * argv[]) {
const char *sTest = "request";
rt_init();
NSLog(@"Result=%s",dfunc(sTest));
rt_term();
return NSApplicationMain(argc, argv);
}
source
share