本文介绍了我可以使用C ++ 11与Xcode吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑在一些跨平台项目(Windows + Mac)中使用一些C ++ 11功能(例如 auto )。在Windows上,Visual Studio支持即将到来的C ++ 11标准的一部分,这将允许我简化代码库的一部分,所以我很想开始使用这些功能。



但据我所知,目前的XCode版本(3.2.4 + GCC 4.2)不支持任何C ++ 11功能。我可以升级GCC版本或CLang版本吗?

解决方案

Xcode 4.2终于开始了添加对C ++ 0X的支持:


  1. 在项目构建设置屏幕中,打开所有选项。 >


  2. 在构建选项部分中,将编译器设置为Apple LLVM compiler 3.0。


  3. 向下滚动到Apple LLVM Compiler 3.0 - 语言部分,并将C ++语言方言设置为C ++ 0X,将C ++标准库设置为libc ++。


std :: move(),move constructor和R-Value引用已知可以正常工作,我正在测试std :: thread和std :: atomic。


I am considering the use of some C++11 features (like auto for instance) in some cross-platform projects (Windows+Mac). On Windows, Visual Studio supports parts of the upcoming C++11 standard that would allow me to simplify parts of the code base so naturally I would be interested in starting to use these features.

But as far as I am aware, the current XCode version (3.2.4 + GCC 4.2) does not support any C++11 features at all. Can I upgrade the GCC version or the CLang version somehow? Or should I just bite my tongue and wait for Apple to package a new version sometime in the future?

解决方案

Xcode 4.2 had finally added support for C++0X:

  1. In the project build settings screen, switch on "All" options.

  2. In the "Build Options" section, set compiler to "Apple LLVM compiler 3.0".

  3. Scroll down to "Apple LLVM Compiler 3.0 - Language" section and set "C++ Language Dialect" to "C++0X" and "C++ Standard Library" to "libc++".

The std::move(), move constructor and R-Value reference are known to work as expected, and I'm testing on the std::thread and std::atomic.

这篇关于我可以使用C ++ 11与Xcode吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 09:07