dysmondad via Digitalmars-d-learn
2014-10-16 03:18:49 UTC
Since I've added this call, my program will sometimes but not
always either generate a core dump or a seg fault. It seems that
the issue is with the const char * parameter.
I don't have a good grasp of the difference between the way D and
C work for char * types. The call to loadTexture uses a literal
for the file name, i.e. "resources/ball.png".
// d lang bindings for C function
alias void SDL_Renderer;
alias void SDL_Texture;
extern (C) SDL_Texture * IMG_LoadTexture(SDL_Renderer * renderer,
const char * file);
// d lang call to extern (C) function
SDL_Texture* loadTexture( SDL_Renderer * ren, const char * file )
{
SDL_Texture * loadedImage = IMG_LoadTexture( ren, file );
return loadedImage;
}
always either generate a core dump or a seg fault. It seems that
the issue is with the const char * parameter.
I don't have a good grasp of the difference between the way D and
C work for char * types. The call to loadTexture uses a literal
for the file name, i.e. "resources/ball.png".
// d lang bindings for C function
alias void SDL_Renderer;
alias void SDL_Texture;
extern (C) SDL_Texture * IMG_LoadTexture(SDL_Renderer * renderer,
const char * file);
// d lang call to extern (C) function
SDL_Texture* loadTexture( SDL_Renderer * ren, const char * file )
{
SDL_Texture * loadedImage = IMG_LoadTexture( ren, file );
return loadedImage;
}