Osx Lion:Xcode 4.1 如何设置 c++0x 项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7226753/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 21:49:55  来源:igfitidea点击:

Osx Lion: Xcode 4.1 how do I setup a c++0x project

xcodemacososx-lionc++11libc++

提问by moka

I know there have been other questions like that but (i.e. Can I use C++11 with Xcode?) but mostly related to older versions of Osx or xcode so they don't really seem to be the right solution to go on Osx Lion and xcode 4.1. What are the requirements on osx Lion to use c++0x features? I think i'd have to set LLVM 3.0 as the compiler somehow using the new libc++ as the standard library. Is there a default way to get LLVM 3.0 to work on lion?

我知道还有其他类似的问题,但是(即我可以在 Xcode 中使用 C++11 吗?)但主要与旧版本的 Osx 或 xcode 相关,因此它们似乎并不是继续使用 Osx Lion 的正确解决方案和 xcode 4.1。在 osx Lion 上使用 c++0x 特性有什么要求?我想我必须将 LLVM 3.0 设置为编译器,以某种方式使用新的 libc++ 作为标准库。有没有默认方法可以让 LLVM 3.0 在 Lion 上工作?

Edit: Okay it seems its just a matter of time till LLVM 3.0 will become part of xcode 4: http://oleb.net/blog/2011/07/whats-new-for-developers-in-lion-part-1/

编辑:好的,LLVM 3.0 成为 xcode 4 的一部分似乎只是时间问题:http: //oleb.net/blog/2011/07/whats-new-for-developers-in-lion-part-1 /

回答by bames53

In Xcode 4.1 you can use the 'other' flags to get access to the compiler's C++0x support, such as it is (Actually I'm not sure what level it's at right now, and I can't check it right now). The latest version of clang have much better support than the version that was shipped with Xcode 4.1. Xcode 4.2 should have the updated compiler and added language and library selection options.

在 Xcode 4.1 中,您可以使用“其他”标志来访问编译器的 C++0x 支持,例如(实际上我不确定它现在处于什么级别,我现在无法检查它)。最新版本的 clang 比 Xcode 4.1 附带的版本有更好的支持。Xcode 4.2 应该有更新的编译器和添加的语言和库选择选项。

So, to get C++0x support in Xcode 4.1 add the flags -std=c++0x -stdlib=libc++ to the compiler and -stdlib=libc++ to the linker. You might also need -U__STRICT_ANSI__ on the compiler (apparently if __STRICT_ANSI__is defined it triggers a bug in the system headers).

因此,要在 Xcode 4.1 中获得 C++0x 支持,请将标志 -std=c++0x -stdlib=libc++ 添加到编译器并将 -stdlib=libc++ 添加到链接器。您可能还需要在编译器上使用-U__STRICT_ANSI __(显然,如果定义了__STRICT_ANSI_ _它会触发系统头文件中的错误)。