Reputation: 10927
When running the following D code I get a strange SDL error:
import std.string;
import derelict.sdl2.sdl;
pragma(lib, "DerelictUtil");
pragma(lib, "DerelictSDL2");
int main(){
DerelictSDL2.load();
if(SDL_Init(SDL_INIT_VIDEO) < 0){
throw new Exception(format("Error initalizing SDL: %s", SDL_GetError()));
}
return 0;
}
Which returns the following from SDL_GetError()
[email protected](12): Error initalizing SDL: 7F2802391940
----------------
./min(extern (C) int rt.dmain2.main(int, char**).void runMain()+0x1c) [0x434284]
./min(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate())+0x2a) [0x433bfe]
./min(extern (C) int rt.dmain2.main(int, char**).void runAll()+0x3b) [0x4342cb]
./min(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate())+0x2a) [0x433bfe]
./min(main+0xd1) [0x433b89]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7f28023b776d]
----------------
I am running this against the latest version of SDL2, built from mercurial. The d code is compiled with dmd v2.060. It looks like the number 7F2802391940 is garbage, but calling SDL_ClearError beforehand still produces a similar hex error message.
Upvotes: 1
Views: 575
Reputation: 25187
7F2802391940
is probably the address of the error message (stored as a null-terminated string). D's format
function doesn't understand those (or rather, treats them like any other pointer), so convert it to a D string explicitly with text(SDL_GetError())
(don't forget to import std.conv
).
Upvotes: 2