Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i use the latest features of C++11 in XCode 4 or OSX Lion? [duplicate]

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?

like image 913
Per Arneng Avatar asked Sep 20 '11 08:09

Per Arneng


4 Answers

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.

like image 84
bames53 Avatar answered Sep 23 '22 16:09

bames53


Each version of Xcode 4 adds new compiler support features. Please try Xcode 4.2 when it comes out.

like image 44
Chris Lattner Avatar answered Sep 23 '22 16:09

Chris Lattner


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.

like image 39
rubenvb Avatar answered Sep 23 '22 16:09

rubenvb


Consider using Clang++ with libc++ http://libcxx.llvm.org/

It supports Mac OS X and has about 98% C++0x features finished except atomics.

like image 44
will Avatar answered Sep 20 '22 16:09

will