Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Const-Qualification of Main's Parameters in C++

The C++ standard mandates that all conforming implementations support the following two signatures for main:

  • int main();
  • int main(int, char*[]);

In case of the latter signature, would the addition of (top-level) const-ness break any language rules?

For example:

int main(const int argc, char** const argv);

From my understanding, top-level const qualification doesn't affect the function's signature hash, so it should be legal as far as the specification is concerned.

Also, did anyone ever encounter an implementation which rejected this type of modification?

like image 611
pt2cv Avatar asked Jun 13 '10 23:06

pt2cv


1 Answers

This is a known issue in the Standard. Also see this usenet discussion on the topic.

like image 71
Johannes Schaub - litb Avatar answered Sep 30 '22 08:09

Johannes Schaub - litb