//OK... this is nasty. //SDL hijacks the main function, then calls our main function (which has actually //been renamed to SDL_main by a macro) back. // //Except something has gone horribly wrong. Someone somewhere seems to think we're //a GUI app and is trying to call WinMain. So provide a fake WinMain which makes sure //the main function in SDL_main.c is called, and also calls our "main" function. // //This should go at the end of the file so that the macro doesn't mess anything up //(You can tell things are getting nasty if "#undef main" is capable of screwing things up) // //gcc will emit a warning, but - bless its little cotton socks - it will compile for us anyway. inline int call_main(int argc, char *argv[]){return main(argc, argv);} #undef main extern "C" int main(int argc, char *argv[]); //prototype the main function, because we will call it. extern "C" int WinMain(int argc, char *argv[]) { static bool first=true; if (first) { first=false; //call the function which really is called "main" return main(argc, argv); } else { //call the function which appears to be called "main" return call_main(argc, argv); } }