Possible Duplicate:
Is main() overloaded in C++?
here's my code:
#include <iostream>
int main(void* a, void* b)
{
std::cout << "hello standalone " << std::endl;
return 0;
}
different parameters should have a different symbol name after name mangling(void* a, void* b)
should be different from (int, char**
), but this program doesn't have any problem when running.
Why is that?
It depends on the compiler. The standard required signatures for main are:
But besides these, the compiler is free to provide other signatures as well.
For example, gcc 4.3.4 rejects your code - http://ideone.com/XZp2h
MSVS complains about unresolved externals.
Because
main
is a special case, and the compiler generates special code for it. Typically,main
will be called from a startup routine—often calledcrt0
in older compilers—written in C, so the compiler will generatemain
as if it were declaredextern "C"
. But that's in no way required; it's a just a typical implementation.