Advertisement

(SDL) Simply including sdl crashes it...

Started by August 31, 2011 03:41 AM
3 comments, last by spaz102 13 years, 6 months ago
In a fresh codeblocks project, Main.cpp:
#include <sdl/sdl.h>

int main(int argc, char *argv[]) {
return 1;
}

Yet it returns 0 instead of 1.

This is the boiled down version of the problem I'm having with my actual program, where it compiles without error, and then returns 0 before actually doing anything. I'm using codeblocks with the sdl.dll sitting in the project folder. It used to work fine until today - any ideas? For now, I'm going to assume reinstalling codeblocks and/or rebooting might help.
I'm guessing you've already included 'mingw32', 'sdlmain' and 'sdl', but just in case, check that.

Else, right-click the project>Build Options...>Linker Settings and add them.

But considering it actually worked before this may not be the case.

Advertisement
After reinstalling codeblocks and setting it up with sdl again, I cleared out my previous linker settings and re-added the three you suggested. The program still seems to always return 0, but it properly runs a SDL_Delay(1000) I added first, which is new :) So at least the dummy program is actually running -some- code, but my actual program still doesn't (Not even that same delay)
SDL wraps your main() function to allow you to use the same code in a cross platform manner. The function you define is #defined to be SDL_main(). The Windows implementation appears to unconditionally return 0 from the platform specific main, regardless of the return value of SDL_main().
Ah, thank you! This is what I needed to know to confirm my suspicions. So my program is crashing elsewhere, and it's a (relatively) simple matter of finding the logical rather than syntax or compiler error.

This topic is closed to new replies.

Advertisement