問題描述
我正在考慮在一些跨平臺項目(Windows+Mac)中使用一些 C++11 特性(例如 auto
).在 Windows 上,Visual Studio 支持即將推出的 C++11 標準的部分內(nèi)容,這將使我能夠簡化部分代碼庫,因此我自然會對開始使用這些功能感興趣.
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.
但據(jù)我所知,當(dāng)前的 XCode 版本(3.2.4 + GCC 4.2)根本不支持任何 C++11 功能.我可以以某種方式升級 GCC 版本或 CLang 版本嗎?或者我應(yīng)該咬咬牙,等蘋果在未來某個時候打包一個新版本?
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:
在項目構(gòu)建設(shè)置屏幕中,打開所有"選項.
In the project build settings screen, switch on "All" options.
在構(gòu)建選項"部分,將編譯器設(shè)置為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"設(shè)置為C++0X",將C++ Standard Library"設(shè)置為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()、移動構(gòu)造函數(shù)和 R 值引用按預(yù)期工作,我正在測試 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.
這篇關(guān)于我可以在 Xcode 中使用 C++11 嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!