I'm having some trouble with C++11 in Xcode

ぐ巨炮叔叔 提交于 2019-12-01 06:10:43

I use Xcode and set the following settings:

C++ language dialect: C++11 or GNU++11

C++ Standart Library: libc++ (LLVM C++ standart library with C++11 support)

Xcode version: 4.3.2

If you're using Xcode 4.3 there are several relevant project settings you need to use C++11 features. The first is to use the clang compiler. Something like

GCC_VERSION = com.apple.compilers.llvm.clang.1_0

in your .xcconfig will set it, or you can use the GUI.

Next, you need to tell LLVM which C++ standard to use:

CLANG_CXX_LANGUAGE_STANDARD = gnu++11

This will make language features like range based for, delegated constructors, etc. available.

Finally, if you want to use C++11 STL features (such as std::unordered_map) you need to use the libc++ STL:

CLANG_CXX_LIBRARY = libc++

On XCode 5 / opencv 2.4.9, I can select:

And it builds without error. If i set the libc++ without specifying C++ Language Dialect then I get same issue as OP

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!