问题
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?
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/
回答1:
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.
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).
来源:https://stackoverflow.com/questions/7226753/osx-lion-xcode-4-1-how-do-i-setup-a-c0x-project