Search code examples
c++c++11wxwidgetsxcode4.5

XCode 4.5 'tr1/type_traits' file not found


I use the wxwidget library and I have the following problem:

#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

here the #include isn't found. I use the Apple LLVM compiler 4.1. (with the c++11 dialect). If I switch to the LLVM GCC 4.2 compiler I have no error there, but the main problem is that all the c++11 inclusions won't work.

How can I either use the GCC compiler, but with the c++11 standard or make it that the LLVM can find the ?

any help would be really appreciated.


Solution

  • I'm guessing you have "C++ Standard Library" set to "libc++". If this is the case, you want <type_traits>, not <tr1/type_traits>. libc++ gives you a C++11 library, whereas libstdc++ (which is also the default in Xcode 4.5) gives you a C++03 library with tr1 support.

    If you want, you can auto-detect which library you're using with:

    #include <ciso646>  // detect std::lib
    #ifdef _LIBCPP_VERSION
    // using libc++
    #include <type_traits>
    #else
    // using libstdc++
    #include <tr1/type_traits>
    #endif
    

    Or in your case perhaps:

    #include <ciso646>  // detect std::lib
    #ifdef _LIBCPP_VERSION
    // using libc++
    #define HAVE_TYPE_TRAITS
    #else
    // using libstdc++
    #define HAVE_TR1_TYPE_TRAITS
    #endif