Xcode 4.5 'tr1 / type_traits' not found

I am using 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 

#include not found here. I am using the Apple LLVM 4.1 compiler. (with C ++ 11 dialect). If I switch to the LLVM GCC 4.2 compiler, I don't have an error there, but the main problem is that all C ++ 11 inclusions will not work.

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

any help would be really appreciated.

+6
source share
3 answers

I assume that you have the "C ++ Standard Library" installed on "libC ++". If so, you want <type_traits> , not <tr1/type_traits> . libC ++ gives you the C ++ 11 library, while libstdC ++ (which is also the default in Xcode 4.5) gives you the C ++ 03 library with tr1 support.

If you want, you can automatically determine which library you are using:

 #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 it’s possible:

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

This is the command I used to build wxWidgets for libC ++ (LLVM C ++ Standard Library). Must work on Yosemite and later (at least until Apple breaks it all again):

 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 
+1
source

Slightly modified the code above to avoid compiler complaints:

Paste the following into strvararg.h before #ifdefined (HAVE_TYPE_TRAITS)

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

All Articles