找不到XCode 4.5'tr1/type_traits'文件

Ara*_*nir 7 c++ wxwidgets c++11 xcode4.5

我使用wxwidget库,我有以下问题:

#if defined(HAVE_TYPE_TRAITS)
    #include <type_traits>
#elif defined(HAVE_TR1_TYPE_TRAITS)
    #ifdef __VISUALC__
        #include <type_traits>
    #else
        #include <tr1/type_traits>
    #endif
#endif
Run Code Online (Sandbox Code Playgroud)

这里找不到#include.我使用Apple LLVM编译器4.1.(使用c ++ 11方言).如果我切换到LLVM GCC 4.2编译器,我没有错误,但主要问题是所有c ++ 11包含都不起作用.

我如何使用GCC编译器,但使用c ++ 11标准或使LLVM可以找到?

任何帮助将非常感激.

How*_*ant 13

我猜你有"C++标准库"设置为"libc ++".如果是这种情况,你想要的<type_traits>不是<tr1/type_traits>.libc ++为您提供了一个C++ 11库,而libstdc ++(它也是Xcode 4.5中的默认值)为您提供了一个支持tr1的C++ 03库.

如果需要,您可以自动检测您正在使用的库:

#include <ciso646>  // detect std::lib
#ifdef _LIBCPP_VERSION
// using libc++
#include <type_traits>
#else
// using libstdc++
#include <tr1/type_traits>
#endif
Run Code Online (Sandbox Code Playgroud)

或者在你的情况下:

#include <ciso646>  // detect std::lib
#ifdef _LIBCPP_VERSION
// using libc++
#define HAVE_TYPE_TRAITS
#else
// using libstdc++
#define HAVE_TR1_TYPE_TRAITS
#endif
Run Code Online (Sandbox Code Playgroud)


Eli*_*iot 5

这是我针对libc ++(LLVM C ++标准库)构建wxWidgets的命令。应该适用于优胜美地及更高版本(至少直到苹果再次破坏一切):

mkdir build-cocoa-debug
cd build-cocoa-debug
../configure --enable-debug --with-macosx-version-min=10.10
make -j8 #This allows make to use 8 parallel jobs
Run Code Online (Sandbox Code Playgroud)