Possible Duplicate:
Can I use C++11 with Xcode?
It seems like xcode 4 contains older versions of clang and gcc. Can i uppgrade gcc or clang and use them with xcode 4? I would like to use gcc >= 4.6 or the latest clang.
My main goal is to be able to have as much of the new features from C++11 available when programming C++ on mac osx lion so ditching xcode is also an option if that is needed.
What are my options to achieve this?
The version of clang in Xcode 4.1 does support some C++11 features, including variadic templates and rvalue references. Also libc++, an implementation of the C++11 standard library is included in Lion.
See my answer to Osx Lion: Xcode 4.1 how do I setup a c++0x project for details on setting this up.
Each version of Xcode 4 adds new compiler support features. Please try Xcode 4.2 when it comes out.
Macports provides GCC 4.6, but any GCC version >= 4.2.1 (ie the latest official Apple GCC) cannot create universal binaries (32 and 64-bit code in one file) directly. There may be other drawbacks, but otherwise this should work for you.
Consider using Clang++ with libc++ http://libcxx.llvm.org/
It supports Mac OS X and has about 98% C++0x features finished except atomics.
Turns out that XCode 4.2.0 (the latest version compatible with Snow Leopard) only comes with CLANG 2.0, so no C++ '11 stuff. (Even XCode 4.2.1 still uses CLANG 2.0, so it seems like you need at least XCode 4.2.3 and Lion to use any C++ '11.
I recently spent a bit of time installing Macports GCC 4.6 and modifying some Xcode compiler templates so I could select and use it from my Xcode projects. I did eventually get it working, the main drawback was that GCC 4.6 doesn't know what to do with "blocks". If you are planning on doing any COCOA, GUI stuff then this probably isn't a good option for you (as a bunch of the NS Object header files contain blocks, you get stopped pretty early).
If you are doing any other kind of project you can probably get it to work with this method.
You can even get it to create universal binaries with some creativity. I have all the gory details on how I accomplished this here:
http://thecoderslife.blogspot.com/2015/07/building-with-gcc-46-and-xcode-4.html