Eclipse 上的 C++11 完全支持
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22074724/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C++11 full support on Eclipse
提问by Jerome
I am trying to find a way to get full C++11 support on Eclipse.
我正在尝试找到一种在 Eclipse 上获得完整 C++11 支持的方法。
In Eclipse Juno I had a lot of new features with __GXX_EXPERIMENTAL_CXX0X__
but I didn't find support for std::threads
, std::mutex
, etc.
在Eclipse朱诺我有很多的新功能__GXX_EXPERIMENTAL_CXX0X__
,但我没有找到支持std::threads
,std::mutex
等等。
How can I have completion for all C++11 functions?
如何完成所有 C++11 函数?
EDIT : Solution
编辑:解决方案
Go to Project -> Properties -> C/C++ General -> Path and Symbols -> Tab [Symbols]
.
Add the symbol : __cpluspluswith the value 201103L
去Project -> Properties -> C/C++ General -> Path and Symbols -> Tab [Symbols]
。添加符号:__cplusplus,值为201103L
采纳答案by lapk
Eclipse works with C+11 support (Indexer and such) just fine: both Juno and Kepler. The thing is that you have to let Eclipse know that you are going to compile with C++11 support. This is done by providing additional flag -std=c++11
to CDT GCC Builtin Compiler Settings
in C/C++ -> Build -> Settings -> Discovery [tab]
so it will read something like:
Eclipse 可以很好地支持 C+11(索引器等):Juno 和 Kepler。问题是您必须让 Eclipse 知道您将使用 C++11 支持进行编译。这是通过向in提供附加标志-std=c++11
来完成的CDT GCC Builtin Compiler Settings
,C/C++ -> Build -> Settings -> Discovery [tab]
因此它将读取如下内容:
${COMMAND} -E -P -v -dD "${INPUTS}" -std=c++11
And that is all you have to do with Kepler/Juno to get C++11 code highlighted correctly.
这就是使用 Kepler/Juno 正确突出显示 C++11 代码所需要做的全部工作。
Note, this is workspace-wide setting. You can do the same on per project basis if you don't want to set it in workspace.
请注意,这是工作区范围的设置。如果您不想在工作区中设置它,您可以在每个项目的基础上执行相同的操作。
回答by Christian Hackl
Is there even a compiler which fullysupports C++11? If you are on Windows, then I think you should give Microsoft Visual Studio Express Edition 2013a try. Its C++11 support is not complete but IMO fairly good, and it looks like it will get even better in the near future.
甚至有完全支持 C++11的编译器吗?如果您使用的是 Windows,那么我认为您应该尝试一下Microsoft Visual Studio Express Edition 2013。它的 C++11 支持并不完整,但 IMO 相当不错,而且看起来在不久的将来会变得更好。