-
A hosted implementation shall contain a global function called main in one of the specified forms [basic.start.main]
- 6.8.3.1
- Example:
void main() {}
-
Rationale:
-
Tools
-
The function main shall not be used within a program [basic.start.main]
-
6.8.3.1
-
Examples:
- Is it illegal to take address of main() function?
- Why does gcc warn about decltype(main()) but not clang?
printf( “%p\n”, &main ) ; decltype(main()) x = 0;
int main() { std::cout << reinterpret_cast<void*>(&main) ; }
-
Tools
-
Rationale:
- From ARM section 3.4 Start and Termination
This is to ensure full freedom of the implementation of the interface between a C++ program and its environment. One could imagine an implementation where main() was not implemented as a function.
- [ub] What does "The function main shall not be used within a program" mean?
- From ARM section 3.4 Start and Termination
-