我遇到了一个非常奇怪的错误,只有在使用 ansi
标志时才会出现。
#include <memory>
class Test
{
public:
explicit Test(std::shared_ptr<double> ptr) {}
};
这是编译结果,已经在gcc 4.5.2和4.6.0 (20101127)上测试过:
g++ -std=c++0x -Wall -pedantic -ansi test.cpp
test.cpp:6:34: error: expected ')' before '<' token
但是没有使用-ansi
编译也可以工作。为什么?