In C and C++, "main" is special. Too special. For historical reasons, its argument and return types are not checked.
I once argued on the C standard forum that a C compiler should not know about "main". "#include <unix.h>" should contain the usual Unix declaration for "main", and "#include <windows.h>" should contain the Windows declaration, which at the time was, roughly:
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow);
It's then up to the user to define their startup function to match, with normal type checking.
This gets the compiler out of handling "main" as a special case.
This was generally considered to be the right answer, but would break too much existing code.
I once argued on the C standard forum that a C compiler should not know about "main". "#include <unix.h>" should contain the usual Unix declaration for "main", and "#include <windows.h>" should contain the Windows declaration, which at the time was, roughly:
It's then up to the user to define their startup function to match, with normal type checking.This gets the compiler out of handling "main" as a special case.
This was generally considered to be the right answer, but would break too much existing code.