On 5/16/18 11:07 AM, Robert M. Münch wrote:
I have an extern(C) function in a DLL with this signature:

result* myfunc(double x, double y, const char *text, stuff *myStuff, bool flag);

I call it like this:

result = myfunc(0, 0, std.string.toStringz("1"), stuff, true);

toStringz isn't necessary, string literals always are null terminated, and implicitly cast to const char *.

The problem is, that on the DLL side *text is always NULL. I doesn't matter what I put as third argument. And even more strange, I have an other function with a const char* as first argument. There everything is working...

Any idea what cause this could be? This is really strange...

It sounds very much like a mismatch of parameters on the prototype. Anything extern(C) has no mangling, and so you can specify the wrong parameters and it still compiles.

Double check the parameter types, and if possible, reduce to a simple compilable example that can be tested by others.

-Steve

Reply via email to