C API / const char *text / std.string.toStringz pointer is always NULL on C side

Steven Schveighoffer schveiguy at yahoo.com
Wed May 16 17:46:59 UTC 2018


On 5/16/18 12:53 PM, Robert M. Münch wrote:
> On 2018-05-16 15:09:41 +0000, rikki cattermole said:
> 
>> On 17/05/2018 3: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);
>>>
>>>
>>> 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...
>>
>> Please post the C function prototype.
> 
> Well, for C see above on the D side:
> 
>      extern(C) {
>            result myfunc(double x, double y, const char *text, stuff 
> *myStuff, bool measureOnly);
>      }

Shouldn't the result be a pointer?

-Steve


More information about the Digitalmars-d-learn mailing list