Xcode 5.1 启用 C++14
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22952314/
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
Xcode 5.1 enable C++14
提问by Troy Harvey
Xcode 5.1 using Clang 3.4. And Clang 3.4 supports C++14.
Xcode 5.1 使用 Clang 3.4。并且 Clang 3.4 支持 C++14。
However, I've been surfing though all of the Xcode options and don't see a way to enable C++14.
但是,我一直在浏览所有 Xcode 选项,但没有看到启用 C++14 的方法。
I'm trying to enable the relaxed constexprfeature of C++14
我正在尝试启用C++14的宽松constexpr功能
回答by jbruni
To get this to work, you first set "C++ Language Dialect" to "compiler default". Then in "Other C++ flags" add "-std=c++1y".
要使其工作,首先将“C++ 语言方言”设置为“编译器默认值”。然后在“其他 C++ 标志”中添加“-std=c++1y”。
This will allow Clang++ to compile with c++14 from within Xcode. I tested this with Xcode 5.1.1 using the new user defined literal for basic_string:
这将允许 Clang++ 在 Xcode 中使用 c++14 进行编译。我使用 Xcode 5.1.1 使用新的用户定义的 basic_string 字面量对此进行了测试:
std::string word = "hello"s;
Update: As of Xcode 6, c++14 is available as a first-class language dialect.
更新:从 Xcode 6 开始,c++14 可用作一流的语言方言。
回答by Joseph Ian Walker
With Xcode Version 8.2 (8C38) you click on the project name in the project navigator (click on the little folder at the left of the window to get to this) then in the middle pane of the ide, you click on build settings (up the top of the middle pane), then you can scroll to find the Apple LLVM 8.0 - Language - C++ section. There is a C++ Language Dialect section; select C++14 [-std-c++=14] from the spinner. This then compiles properly.
使用 Xcode 版本 8.2 (8C38),您在项目导航器中单击项目名称(单击窗口左侧的小文件夹以到达该文件夹),然后在 ide 的中间窗格中,单击构建设置(向上中间窗格的顶部),然后您可以滚动以找到 Apple LLVM 8.0 - Language - C++ 部分。有一个 C++ Language Dialect 部分;从微调器中选择 C++14 [-std-c++=14]。然后正确编译。