According to the C++11 standard, is the following program well-formed and portable C++?
int main(int argc, char const* const* argv) {}
No. In a pure portable C++ program, the argv
argument, if present, has no const
modifiers.
Edit: See section 3.6.1.2 of the C++11 draft standard, which (in the version I have before me) states:
An implementation shall not predefine the main function. This function shall not be overloaded. It shall have a return type of type int, but otherwise its type is implementation-defined. All implementations shall allow both of the following definitions of main:
int main(){ /*...*/ }
and
int main(int argc, char* argv[]) { /* ... */ }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With