On Wednesday, 20 February 2013 at 14:28:06 UTC, Chris wrote:
On Wednesday, 20 February 2013 at 14:05:40 UTC, Mike Parker
wrote:
Your function is being called from Python, correct? Then in
addition to the extern(C), the argument needs to be a char*,
not a D array or a reference to one.
Correct, and it works _now_*! The lines
printf("Incoming printf: %s\n", str);
writefln("writefln %s", to!string(str));
Print now:
Incoming printf: Hello from Python
writefln Hello from Python
So the correct signature is
extern (C) {export void printThis(char* str);}
Thanks you guys! I'm so glad I don't have to write a C-wrapper!
*("_now_" because I tried char* with extern (C) before as I
would in my other Python modules, but it didn't work for some
reason. Must have overlooked something. Mea culpa!).
yeah, although extern(C) doesn't have to have any braces.
I've never had to use export before, but then that could be a
.so/.dylib vs .dll thing