如何在 Clang 中使用 C++ 11 功能?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10408849/
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
How can I use C++ 11 features in Clang?
提问by Sergey K.
How can I use the latest C++ 11 features in Clang? What (sub)set of features is supported?
如何在 Clang 中使用最新的 C++ 11 功能?支持哪些(子)功能集?
回答by Sergey K.
You will need clang 3.3 to use the most relevant feature set from C++ 11. Read C++ Support in Clangfor the complete list of up-to-date supported features. Clang 3.3 is claimed to be C++11 feature complete.
您将需要 clang 3.3 才能使用 C++ 11 中最相关的功能集。请阅读Clang中的C++ 支持以获取最新支持功能的完整列表。Clang 3.3 声称已完成 C++11 功能。
Clang's command line is gcc-compatible so you have to enable C++11 support via the followinf command-line switch
Clang 的命令行与 gcc 兼容,因此您必须通过 followinf 命令行开关启用 C++11 支持
-std=c++11
There is also a bunch of post-C++11 features (like decltype(auto), member initializers and aggregates) that are supported by Clang 3.3. Use this command line switch to enable them
Clang 3.3 还支持许多后 C++11 特性(如 decltype(auto)、成员初始值设定项和聚合)。使用此命令行开关启用它们
-std=c++1y
回答by Klaim
Here is the always up to date list of features supported by clang:
以下是 clang 支持的功能的最新列表:
http://clang.llvm.org/cxx_status.html
http://clang.llvm.org/cxx_status.html
To activate C++11, you have to add -std=c++11 in your clang calls, like for gcc. If you use an IDE that is clang-aware or gcc-aware, there is a specific project settings option available to do that.
要激活 C++11,您必须在 clang 调用中添加 -std=c++11,例如 gcc。如果您使用支持 clang 或 gcc 的 IDE,则可以使用特定的项目设置选项来执行此操作。