Summary:
- Explicitly detect use of libc++ in configure.ac and reflect this in
folly-config.h. Do this rather than looking for to pop up organically
_LIBCPP_VERSION since this only exists if we've included some libc++
header files prior to refernce. This isn't always the case, e.g. in
Portability.h.
Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac
Reviewed By: simpkins@fb.com
FB internal diff:
D1002958
// It turns out that GNU libstdc++ and LLVM libc++ differ on how they implement
// the 'std' namespace; the latter uses inline namepsaces. Wrap this decision
// up in a macro to make forward-declarations easier.
-#ifdef _LIBCPP_VERSION
+#if FOLLY_USE_LIBCPP
#define FOLLY_NAMESPACE_STD_BEGIN _LIBCPP_BEGIN_NAMESPACE_STD
#define FOLLY_NAMESPACE_STD_END _LIBCPP_END_NAMESPACE_STD
#else
AC_DEFINE([OVERRIDE], [],
[Define to "override" if the compiler supports C++11 "override"])]
)
+AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE[
+ #include <type_traits>
+ #if !_LIBCPP_VERSION
+ #error No libc++
+ #endif
+ void func() {}]
+ ],
+ [AC_DEFINE([USE_LIBCPP], [1], [Define to 1 if we're using libc++.])])
# Check for clock_gettime(2). This is not in an AC_CHECK_FUNCS() because we
# want to link with librt if necessary.
*/
#include "folly/ScopeGuard.h"
+#include "folly/Portability.h"
#include <gflags/gflags.h>
#include <gtest/gtest.h>
throw std::runtime_error("destructors should never throw!");
});
},
-#ifdef _LIBCPP_VERSION
+#if FOLLY_USE_LIBCPP
"terminate called throwing an exception"
#else
"destructors should never throw"