如何在 Eclipse CDT 中启用 C++11/C++0x 支持? [英] How to enable C++11/C++0x support in Eclipse CDT?
问题描述
Eclipse 3.7.1CDT 1.4.1海湾合作委员会 4.6.2
Eclipse 3.7.1 CDT 1.4.1 GCC 4.6.2
这是一段 C++11 代码的例子:
This is an example of a piece of C++11 code:
auto text = std::unique_ptr<char[]>(new char[len]);
Eclipse 编辑器抱怨:
The Eclipse editor complains about:
Function 'unique_ptr' could not be resolved
Makefile 编译工作正常.如何让 Eclipse 停止抱怨此类错误?
The Makefile compilation works fine. How to make Eclipse stop complaining about these sort of errors?
推荐答案
I found this 文章,只需按照这些步骤操作,它就对我有用.我在带有 Cygwin 设置的 Windows 上使用 Eclipse Indigo 20110615-0604.
I found this article in the Eclipse forum, just followed those steps and it works for me. I am using Eclipse Indigo 20110615-0604 on Windows with a Cygwin setup.
- 创建一个新的 C++ 项目
- 所有内容的默认选项
- 创建后,右键单击项目并转到属性"
- C/C++ Build -> Settings -> Tool Settings -> GCC C++ Compiler -> Miscellaneous -> Other Flags.将
-std=c++0x
(或对于较新的编译器版本-std=c++11
放在最后......而不是 GCC C++ Compiler 我也有Cygwin 编译器 - C/C++ 通用 -> 路径和符号 -> 符号 -> GNU C++.单击添加..."并将
__GXX_EXPERIMENTAL_CXX0X__
(确保附加和前置两个下划线)粘贴到名称"中,并将值"留空. - 点击应用,执行它要求你做的任何事情,然后点击确定.
- Make a new C++ project
- Default options for everything
- Once created, right-click the project and go to "Properties"
- C/C++ Build -> Settings -> Tool Settings -> GCC C++ Compiler -> Miscellaneous -> Other Flags. Put
-std=c++0x
(or for newer compiler version-std=c++11
at the end . ... instead of GCC C++ Compiler I have also Cygwin compiler - C/C++ General -> Paths and Symbols -> Symbols -> GNU C++. Click "Add..." and paste
__GXX_EXPERIMENTAL_CXX0X__
(ensure to append and prepend two underscores) into "Name" and leave "Value" blank. - Hit Apply, do whatever it asks you to do, then hit OK.
现在 Eclipse FAQ 中也有对此的描述:Eclipse 常见问题解答/C++11 特性.
There is a description of this in the Eclipse FAQ now as well: Eclipse FAQ/C++11 Features.
这篇关于如何在 Eclipse CDT 中启用 C++11/C++0x 支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!