MacOS – the relationship between the OS release, the XCode release, and the default compiler

gccmacosxcode

If you run:

'cc --version' 

or

'c++ --version' 

on a modern OS X with XCode and the command line tools installed (in my case, Mountain Lion with XCode 4.6.x) you will see that the default C compiler and C++ compiler are clang. At some point previously, it was GCC.

I'd like to know: is the change to clang as default attached to the OS revision (e.g. 10.6 vs 10.7), the XCode revision (e.g. 4.5 vs 4.6), some hybrid of the two, or something else altogether?

Best Answer

Xcode version

With a recent release of Xcode, the default compiler was changed from GCC (like you said) to LLVM (clang) - a more modern compiler, with more error options.

It has nothing whatsoever to do with your OS X version.