[cfe-dev] Best way to detect libc++ at compile time?

Jean-Daniel Dupas devlists at shadowlab.org
Fri Jul 20 10:09:20 PDT 2012


Le 20 juil. 2012 à 04:19, Rich E <reakinator at gmail.com> a écrit :

> Hi all,
> 
> I am enabling libc++ in a library that was depending on boost for things such as mutex, thread, shared_ptr, etc., and I have not yet found a way to detect that we are compiling with the libc++ library unless I first include a header from it.  I can do this:
> 
> // framework config.h:
> 
> #include <vector>
> 
> #if defined( _LIBCPP_VERSION )
>     #define USING_LIBCPP
> #endif
> 
> but now every file that wanted to know if we are using libc++ has vector in it. This include is used to determine which standard library we should use, and many things depend on it. Is there a better solution, other than a -D flag to clang?
> 
> Cheers,
> Rich

FWIW, I'm just testing for features I need:

#if __has_include(<thread>)
  #include <thread> // and assume libc++ or any other c++11 compliant library
#endif

Jean-Daniel








More information about the cfe-dev mailing list