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

Adam D. Ruppe destructionator at gmail.com
Fri May 18 14:42:17 UTC 2018


On Friday, 18 May 2018 at 14:06:11 UTC, Robert M. Münch wrote:
> 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.

A value struct return is actually done via a hidden pointer 
parameter (so the function can construct it in-place for the 
caller, a standard optimization), so it just shifted all the 
other arguments to the side, causing one of those 0's to be 
interpreted as the string.


More information about the Digitalmars-d-learn mailing list