[SDL] Segmentation Fault weirdness..
Stephane Marchesin
stephane.marchesin at wanadoo.fr
Sat Jan 22 08:10:43 PST 2005
mo wrote:
>Hi, when I run my executable, I get a Segmentation Fault and it crashes when my
>event loop is written like so:
>
>while(done==0){
> SDL_Event event;
>
> while(SDL_PollEvent(&event)){
> if(event.type==SDL_QUIT) done=1;
> }
>
> keys=SDL_GetKeyState(NULL);
>
> if(keys[SDLK_UP]) y-=1;
> if(keys[SDLK_RIGHT]) x+=1;
> if(keys[SDLK_DOWN]) y+=1;
> if(keys[SDLK_LEFT]) x-=1;
> if(keys[SDLK_ESCAPE]) done=1;
>
> drawframe();
>}
>
>...but if I insert "printf("whatever");" between "keys=SDL_GetKeyState(NULL);"
>and "if(keys[SDLK_UP]) y-=1;" the program runs smoothly until I close it and I
>get another Segmentation Fault. I'm running Slackware 10 with stock gcc and SDL.
>The code is basically a rewrite of the 2nd lesson over at cone3d, but when I
>compile the code from the tutorial, everything works without a hitch... I'm
>seriously stumped by this..
>
So, chances are you have a bug in your code (yay, this happens).
Why don't you send (or send a link to) a whole file that we can compile
and test here ?
Stephane
More information about the SDL
mailing list