Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++11 with Xcode on Mac OS X Snow Leopard

I have project that is at times developed on Windows/Visual Studio 2010 and uses some C++11 features and I need to be able to develop/build on Mac OS X. When I tried to build the project with Xcode I got a lot of errors around new C++11 features and checked the gcc version to find it's pretty old (4.2). It looks like Apple is trying to force developers to pay an unnecessary upgrade to Lion by refusing to allow Xcode 4+ to be downloaded on any other version of Mac OS thus I'm left with Xcode 3.x.

How can I continue to use C++11 on Snow Leopard? Is there a way I can do this and keep Xcode as an IDE?

like image 373
nuit9 Avatar asked Sep 25 '11 02:09

nuit9


People also ask

What version is OS X Snow Leopard?

Mac OS X Snow Leopard (version 10.6) is the seventh major release of macOS, Apple's desktop and server operating system for Macintosh computers. Apple Inc. The world's most advanced operating system. Finely tuned.

What is Xcode on Mac?

Xcode includes everything developers need to create great applications for Mac, iPhone, iPad, Apple TV, and Apple Watch. Xcode provides developers a unified workflow for user interface design, coding, testing, and debugging. The Xcode IDE combined with the Swift programming language make developing apps easy and fun.

How do I update Xcode on my Mac?

Downloading and updating XcodeThe Mac App Store will notify you when an update is available or you can have macOS update automatically as it becomes available. The latest beta version and previous versions of Xcode can be downloaded from the Downloads page. To download Xcode, simply sign in with your Apple ID.


1 Answers

Update feb.25 2012: There are now a lot of features available for you to work with using the latest clang. Maybe you could target 10.6 if you use language features only. If you need library features, you will need 10.7.


given the present (sept.24.2011) state of the Xcode toolset, it's easiest (IMO) to choose another ide or os if you need c++11 support.

the fork of gcc xcode uses will never support these features. clang is pretty far behind wrt c++11 features (because its c++ implementation is still very new and other compilers have had a few extra years). therefore, the compilers xcode ships with do not presently support enough features for c++11 development, regardless of the version of osx you use.

you can install a newer version of gcc and use another ide fairly easily.

technically, you can also make a plugin for xcode 3 (not officially supported) which invokes another compiler (e.g. a more recent release of gcc). that route has been closed in xc4 (afaik). Update apparently, it's still available in Xc4; see idljarn's comment below.

for many projects, it's easier to just use your mac to boot into linux or windows (or use virtualization).

your final option is intel's compiler, which can be used in xcode and provides a decent amount of c++11 support -- try it with xcode before you buy to see if it fits your needs, plays well with xcode, and supports the c++11 features your team uses.

lastly, i don't think they do this for your upgrade money. they really don't maintain xcode for multiple releases very well - they just expect you to stay with the latest and greatest unless you need backwards compatibility; you just stop upgrading in that case. they invested in and assisted development of clang after gcc's license changed. so yeah... osx has always been very far behind wrt c++11 support because they decided to switch to another (very young) compiler. if you wait for xcode to support c++11, you will have to wait for clang to support it, which can be quite some time.

like image 190
justin Avatar answered Sep 28 '22 16:09

justin