Problem
Why would compiling a program which has an int main(void) main function differ from compiling a program which has an int main(int argc, char *argv[]) main function, if the program does not use arguments passed on the command line?
Is this OS or compiler specific? I do not get the same results using mingw and g++(which is weird isn’t it as wingw is a port of gcc).
Example
Code
#include <iostream>
#include"SDL/SDL.h"
int main(void)
{
return 0;
}
Compilation commands
g++ test.cpp; #g++ 4.4.5
i586-mingw32msvc-g++ test.cpp; # mingw 4.4.4
Error
(Given by the second command.)
a(main.o):(.text+0x85): undefined reference to `_WinMain@16'
This is SDL thing. On Windows, when you include
SDL.h,mainis redefined toSDL_mainwhich callsWinMain(the real entry point in non-console Windows apps), does some initialization and finally calls your main code. It has a signature withargcandargvand you’re pretty much required to follow it, soint main()won’t work.