如何在Eclipse CDT中启用C ++ 11 / C ++ 0x支持? [英] How to enable C++11/C++0x support in Eclipse CDT?
问题描述
Eclipse 3.7.1
CDT 1.4.1
GCC 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?
推荐答案
我发现这篇在Eclipse论坛中的文章,只需遵循这些步骤即可,它对我有用。我在Windows上使用Cygwin设置使用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 ++构建->设置->工具设置-> GCC C ++编译器->其他->其他标志。将
-std = c ++ 0x
(或对于较新的编译器版本-std = c ++ 11
放在最后) 。...除了GCC C ++编译器,我还有Cygwin编译器 - C / C ++ General->路径和符号->符号-> 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 FAQ / 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屋!