【发布时间】:2017-05-13 18:47:10
【问题描述】:
void f() {}
namespace test
{
void f(int) {}
void g() { f(); } // error in gcc 6.2.0
}
int main()
{
test::g();
}
用g++ -std=c++1z main.cpp编译,输出如下:
main.cpp: In function 'void test::g()': main.cpp:9:4: error: too few arguments to function 'void test::f(int)' f(); // error in gcc ^ main.cpp:5:6: note: declared here void f(int) {}
我的编译器是 gcc 6.2.0。
为什么 gcc 会在全局命名空间中隐藏重载函数?这符合 C++ 标准吗?
【问题讨论】:
标签: c++ gcc compiler-errors namespaces language-lawyer