我正在运行 Eclipse Helios,并且安装了 g++-4.6。希望 g++4.6 实现 C++ 11 特性我没有错。我创建了一个使用 nullptr 和 auto 关键字的 C++ 项目。该构建给出以下错误:-
../{filename}.cpp:13:13: error: ‘nullptr’ was not declared in this scope
../{filename}.cpp:14:2: warning: ‘auto’ will change meaning in C++0x; please remove it [-Wc++0x-compat]
实际上,直到昨天它还在 build 中。我今天不知从何而来。请帮我解决这个问题。
最佳答案
要启用 C++0x 支持,请将命令行参数 -std=c++0x 添加到您的 g++ 命令行。或者,要启用除 C++0x 扩展之外的 GNU 扩展,请将 -std=gnu++0x 添加到您的 g++ 命令行。 GCC 4.7 及更高版本也支持 -std=c++11 和 -std=gnu++11。
你是用 -std=gnu++0x
编译的吗?
关于Eclipse IDE 中的 C++ 错误 'nullptr was not declared in this scope',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10033373/