Per the SDL Windows FAQ:
You should be using
main()
instead ofWinMain()
even though you are creating a Windows application, because SDL provides a version ofWinMain()
which performs some SDL initialization before calling your main code.If for some reason you need to use
WinMain()
, take a look at the SDL source code insrc/main/win32/SDL_main.c
to see what kind of initialization you need to do in yourWinMain()
function so that SDL works properly.
SDL requires initialization, so it injects its own main
function that runs its initialization before calling your “main” function, which it renames to SDL_main
so that it does not conflict with the actual main
function. As noted in the FAQ, your main
function must be of the form
int main(int argc, char* argv[])