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

Robert M. Münch robert.muench at saphirion.com
Fri May 18 14:06:11 UTC 2018

On 2018-05-16 17:46:59 +0000, Steven Schveighoffer said:

>> 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?

Indeed. And you know what? That was causing the problem.

So, having a wrong return-type here, resulted in the const char *text 
parameter always being NULL. Not sure I understand the relation but 
looks strange to me... at least not very obvious.

Robert M. Münch
smarter | better | faster
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20180518/28d2531d/attachment.html>

More information about the Digitalmars-d-learn mailing list