Why doesn\'t this compile? The linker can\'t find main, but why is this the case?
namespace somenamespace{
int main(void){
return 0;
}
}
3.6.1/1 - "A program shall contain a global function called main, which is the designated start of the program. It is implementation-defined whether a program in a freestanding environment is required to define a main function. [ Note: in a freestanding environment, start-up and termination is implementation-defined; startup contains the execution of constructors for objects of namespace scope with static storage duration; termination contains the execution of destructors for objects with static storage duration. —end note ]
Your example has 'main' (intended as the program entry point) as a namespace function and hence your code is ill-formed. This does not mean that a function 'main' can not be defined as you did. It just means that a global namespace scope definition of 'main' in accordance with the Standard defined signature is required for a free standing program. hosted program