Help passing D strings to C libs

spir denis.spir at gmail.com
Mon Mar 14 01:13:15 PDT 2011


On 03/14/2011 07:55 AM, Gene P. Cross wrote:
> -Daniel
> I tried what you said:
>
> char* ptr = toStringz(path);
> SDL_LoadBMP(ptr);
>
> and made a check to see if the pointer is null, which it isn't, but I'm unable to
> inspect is value, I haven't a debugger at the moment, could you recommend one ?
>
> I also made the string a char[] and tested to see if that made a difference.
>
> I think it may be something to do with SDL itself. I tried calling another
> function, SDL_GetTicks(), and that's causing problems as well.
>
>
> -Jonathan
> I read the docs earlier and found the same thing about literals being null
> terminated but not regular strings,
> which explains why they work.
> Double check after double check, I am also certain that no other code is messing
> with it and changing values.

I'm surprised about your problem. There is no difference between the .ptr 
property of a null-terminated D char[] and a C "string" (hum). And I'm rather 
sure (not checked the code) that's precisely what toStringZ does. The issue 
must lie on some point you have not mentionned yet.

Denis
-- 
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d-learn mailing list