Is it possible to use C ++ 11 with Xcode?

I am considering using some C ++ 11 features (like auto for example) in some cross-platform projects (Windows + Mac). In Windows, Visual Studio supports parts of the upcoming C ++ 11 standard, which will allow me to simplify parts of the code base, so naturally, I would be interested to start using these functions.

But as far as I know, the current version of Xcode (3.2.4 + GCC 4.2) does not support any C ++ 11 features at all. Can I upgrade the GCC version or CLang version? Or should I just bite my tongue and wait for Apple to pack the new version in the future?

+81
c ++ gcc c ++ 11 xcode clang
Jan 01 '10 at 13:52
source share
4 answers

Xcode 4.2 has finally added C ++ 0X support:

  • On the project build settings screen, enable the "All" options.

  • In the "Build Options" section, install the compiler in "Apple LLVM compiler 3.0".

  • Scroll down to the section "Apple LLVM Compiler 3.0 - Language" and set "C ++ Dialog Language" to "C ++ 0X" and "C ++ Standard Library" to "libC ++".

It is known that std :: move (), move constructor and R-Value work as expected, and I'm testing std :: thread and std :: atomic.

+71
Oct 17 '11 at 9:40
source share

======= Update 2012: =======

Start with Clang - many C ++ 11 features are now available in Clang. It is included in Xcode.

======= Original answer of January 2011: =======

An Intel compiler may be the cleanest way around this time. http://software.intel.com/en-us/articles/intel-composer-xe/

clang is promising, but not particularly stable or recognized by wrt C ++ 0x. C ++ is still very new to clang.

gcc: relatively mature, but you will have to write and maintain your compilers for xcode.

you can also specify custom scenarios, but it’s a pain to maintain ... unless you are struggling and creating an adapter tool.

+8
Jan 02 2018-10-10T00:
source share

Xcode uses GCC or Clang C ++ compilers. Any features supported by these compilers is fair play. The GCC C ++ compatibility page is here , and the Clang C ++ compatibility page is here .

+1
Jan 01 '10 at 19:09
source share

I found auto, decltype () based on the "for (:)" range in a cross-platform project (LLVM for MacOSX, iOS, gcc / linux, MSVC 10 / windows).

lambdas and variable macros do not seem to work in LLVM, but sadly.

0
Nov 27 2018-11-11T00:
source share



All Articles