我可以在 Xcode 中使用 C++11 吗? [英] Can I use C++11 with Xcode?

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

问题描述

我正在考虑在一些跨平台项目(Windows+Mac)中使用一些 C++11 特性(例如 auto).在 Windows 上,Visual Studio 支持即将推出的 C++11 标准的部分内容,这将使我能够简化部分代码库,因此我自然会对开始使用这些功能感兴趣.

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.

但据我所知,当前的 XCode 版本(3.2.4 + GCC 4.2)根本不支持任何 C++11 功能.我可以以某种方式升级 GCC 版本或 CLang 版本吗?或者我应该咬咬牙,等苹果在未来某个时候打包一个新版本?

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 终于添加了对 C++0X 的支持:

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

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

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

在构建选项"部分,将编译器设置为Apple LLVM 编译器 3.0".

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

向下滚动到Apple LLVM Compiler 3.0 - Language"部分,将C++ Language Dialect"设置为C++0X",将C++ Standard Library"设置为libc++".

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

已知 std::move()、移动构造函数和 R 值引用按预期工作,我正在测试 std::thread 和 std::atomic.

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.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆