Eclipse IDE 中的 C++ 错误 'nullptr was not declared in this scope'

标签 c++ g++ eclipse-cdt

我正在运行 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 中。我今天不知从何而来。请帮我解决这个问题。

最佳答案

根据GCC page for C++11 :

要启用 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/

相关文章:

c++ - OpenGL 圆柱体

c++ - 用于创建文件名的预处理器指令

c - 生成编译 gcc 的文件并将对象放入单独的文件夹中

c++ - Eclipse 包括在 gcc 更新后不更新

c++ - 如何将字符串与某些单词进行比较,如果找到匹配项,则打印整个字符串

c++ - 减少内存消耗

assembly - linux g++ x64 通过 FS 段寄存器访问内存

macos - 如何解决我在尝试将 C++ 与 Assembly 链接时遇到的这个链接器错误?

c++ - 使用来自 cygwin 的 g++ C++ 编译器

C++/OpenGL | "undefined reference to ` _imp__ChoosePixelFormat@ 8`"等等