Help passing D strings to C libs
Gene P. Cross
gene_bullydozer_cross at hotmail.com
Sun Mar 13 21:32:49 PDT 2011
Hi, I'm fairly new to D and I'm writing a Space Invaders clone to get myself
acquainted with the language.
I'm having trouble passing D strings (char[]) to SDL, in particular
SDL_LoadBMP(), I keep receiving a segfault.
Heres the code:
void setImg(string path) {
// concat null terminating char to string and cast to c type string when
// passing to SDL_LoadBMP()
path ~= "\0";
image = SDL_LoadBMP( cast(char*)path );
}
and the value of path is "./resources/cannon.bmp"
I'm using SDL 1.2.14 and DMD 1.067 on Ubuntu 10.10
If someone could tell me what I'm doing wrong it would be greatly appreciated.
More information about the Digitalmars-d-learn
mailing list