Derelict / SDL error

Paul via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Dec 10 07:33:59 PST 2014


On Wednesday, 10 December 2014 at 12:10:23 UTC, Mike Parker wrote:
>
> Also, though this is unrelated (I just noticed it when looking 
> at your code again), I strongly recommend you move the line
>
> scope( exit ) SDL_Quit();
>
> to somewhere after DerelictSDL2.load(). If the SDL shared 
> library fails to load for some reason, an exception will be 
> thrown and as the function exits the runtime will happily call 
> SDL_Quit -- even though it will very likely be a null pointer 
> at that point since the library never loaded. Always keep in 
> mind when using Derelict that you're working through function 
> pointers since the shared libraries are loaded manually. If the 
> library fails to load because it was missing, none of the 
> function pointers will be valid. If loading aborts because a 
> function is missing, only the ones loaded before it will have 
> been properly set, so that case should be treated as if they 
> are all invalid.

I see, makes sense!


More information about the Digitalmars-d-learn mailing list