C++中Main主要参数的限定

pt2*_*2cv 10 c++ const signature entry-point

C++标准要求所有符合要求的实现支持以下两个签名main:

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

如果是后一个签名,那么(顶层)const-ness的添加会破坏任何语言规则吗?

例如:

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

根据我的理解,顶级const资格不会影响函数的签名哈希,因此就规范而言它应该是合法的.

还有,有没有人遇到过拒绝这种修改的实现?

Joh*_*itb 5

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