…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…
…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 ?
Ok, here is a tgz of the files: http://thesilent1.freeownhost.com/sdl003.tgz .
I compile it with this command:
gcc sdl003.c -o sdl003 sdl-config --cflags --libs
but a Makefile is included.
You never initialize those two pointers, so when you set scoord->x/y/w/h
and dcoord->x/y you end up corrupting memory.
-Willem JanOn Sat, 2005-01-22 at 18:48 +0000, mo wrote:
Ok, here is a tgz of the files: http://thesilent1.freeownhost.com/sdl003.tgz .
I compile it with this command:
gcc sdl003.c -o sdl003 sdl-config --cflags --libs
but a Makefile is included.
Ok, here is a tgz of the files: http://thesilent1.freeownhost.com/sdl003.tgz . I compile it with
this command: gcc sdl003.c -o sdl003 sdl-config --cflags --libs
but a Makefile is included.
You should always compile with -Wall to enable warnings; they tend to
reveal things you ought to know.–
CalcRogue: TI-89, TI-92+, PalmOS, Windows and Linux. http://calcrogue.jimrandomh.org/
Note that, despite the name, -Wall doesn’t give you anywhere
near “all” of the warnings you could use. I use this:
PKG_CFLAGS := -fno-common -ffast-math
-W -Wall -Wshadow -Wcast-align -Wredundant-decls
-Wbad-function-cast -Wcast-qual -Wwrite-strings -Waggregate-return
-Wstrict-prototypes -Wmissing-prototypes #CFLAGS := -O2 -s # best warnings, compact, fast
CFLAGS := -O1 -ggdb # good debugger support
ALL_CFLAGS := $(PKG_CFLAGS) $(CFLAGS)
Without that -O2 you won’t get all the warnings. The compiler
simply won’t bother to do all the analysis needed.On Sat, 2005-01-22 at 23:42, jimrandomh wrote:
mo wrote:
Ok, here is a tgz of the files: http://thesilent1.freeownhost.com/sdl003.tgz . I compile it with
this command: gcc sdl003.c -o sdl003 sdl-config --cflags --libs
but a Makefile is included.
You should always compile with -Wall to enable warnings; they tend to
reveal things you ought to know.