Help passing D strings to C libs
Daniel Green
venix1 at gmail.com
Sun Mar 13 23:28:01 PDT 2011
On 3/14/2011 1:38 AM, Gene P. Cross wrote:
> I've amended the source to pass the strings pointer (path.ptr) after adding a null
> but the problem still persists.
>
> I lost for what it could be and I'm certain this is where the problem is, because
> if I remove the method call, the program runs fine.
>
> I've noticed that calling SDL_LoadBMP and passing a string literal seems to work,
> instead of a string variable. I might load all the images independently into an
> array and have each object reference that array, instead of every object loading
> its own.
It sounds like a bug with version of D your using. I make heavy use of
toStringz with a lua wrapper I have. If you can debug your program, try
doing something like this.
char* ptr = toStringz(path);
SDL_LoadBMP(ptr);
and inspect ptr before the call to SDL_LoadBMP. I would also replace
string with char[]. To be sure that string isn't really wchar[] or
dchar[]. Although, I imagine the compiler would catch that.
More information about the Digitalmars-d-learn
mailing list