Passing string from D to c++

bsd slackovsky at gmail.com
Tue Jul 30 15:23:53 PDT 2013


(damn, no edit!)

I'm using toStringz() and it works fine if you're c++ function
parms are const ref or by value:

void funk(const std::string& val) {}
void funk(std::string val) {}


then use a very simple D script to auto-generated C wrapper 
functions from headers. All the script does is:

void funkD(const char* c) {funk(c);}

It wouldn't work for functions taking a string by ref or pointer, 
that would require too much effort in the generating script for 
my liking.

You may baulk at the idea of writing a script for auto-generating 
the code but really it is very simple.


More information about the Digitalmars-d mailing list