7

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.

ildjarn
  • 62,044
  • 9
  • 127
  • 211
Aranir
  • 828
  • 1
  • 10
  • 21

3 Answers3

13

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
Howard Hinnant
  • 206,506
  • 52
  • 449
  • 577
5

This is the command I used to build wxWidgets against libc++ (LLVM C++ Standard Library). Should work on Yosemite and later (at least until Apple breaks everything 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
Eliot
  • 5,450
  • 3
  • 32
  • 30
0

Slightly modified the code above, to avoid compiler complaints:

Paste the following into strvararg.h just 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