Better <bits/c++config.h> detection
authorElizabeth Smith <elizabeths@fb.com>
Wed, 23 Apr 2014 20:09:53 +0000 (13:09 -0700)
committerDave Watson <davejwatson@fb.com>
Tue, 20 May 2014 19:53:51 +0000 (12:53 -0700)
Summary:
When worrying about only 2 cpp libraries, detection of "is this libstdc++ or libc++" works, but when throwing in a third option (msvc) this becomes a very brittle way of detecting features.  Also depending on how clang is used it may or may not have this header about

Changed to instead use configuration value for "do we have this header file" for including bits/c++config.h and changed the logic to be identical in all three use cases

Test Plan: fbmake runtests

Reviewed By: njormrod@fb.com

FB internal diff: D1291547

folly/FBString.h
folly/Range.h
folly/Traits.h
folly/configure.ac

index 40e19b53430075f1f05867547d2084adaf4f9381..dd5b0642c267c59ca017bb9826bab56b99061feb 100644 (file)
 #include <type_traits>
 #include <algorithm>
 
-// libc++ doesn't provide this header
-#ifndef _LIBCPP_VERSION
+#include "folly/Portability.h"
+
+// libc++ doesn't provide this header, nor does msvc
+#ifdef FOLLY_HAVE_BITS_CXXCONFIG_H
 // This file appears in two locations: inside fbcode and in the
 // libstdc++ source code (when embedding fbstring as std::string).
 // To aid in this schizophrenic use, two macros are defined in
index fc238b3ee0fcd98400bfca93f4967cf818f655b4..620316ee913ae912aa483bdc6cb1a8a4acc068c3 100644 (file)
@@ -31,8 +31,8 @@
 #include <string>
 #include <type_traits>
 
-// libc++ doesn't provide this header
-#if !FOLLY_USE_LIBCPP
+// libc++ doesn't provide this header, nor does msvc
+#ifdef FOLLY_HAVE_BITS_CXXCONFIG_H
 // This file appears in two locations: inside fbcode and in the
 // libstdc++ source code (when embedding fbstring as std::string).
 // To aid in this schizophrenic use, two macros are defined in
index 9f90fa5678a022c4e8c4a11961d83b8e14fe6d45..bfdf8c708d1fb2c39b9c5e9e308b03e57966dfef 100644 (file)
@@ -26,8 +26,8 @@
 
 #include "folly/Portability.h"
 
-// libc++ doesn't provide this header
-#if !FOLLY_USE_LIBCPP
+// libc++ doesn't provide this header, nor does msvc
+#ifdef FOLLY_HAVE_BITS_CXXCONFIG_H
 // This file appears in two locations: inside fbcode and in the
 // libstdc++ source code (when embedding fbstring as std::string).
 // To aid in this schizophrenic use, two macros are defined in
index 4e9c804104c8c99cbcf7edbe5b098d195fa53403..a93c1ffda867073908fa44b8a39367b3ef270bce 100644 (file)
@@ -52,7 +52,7 @@ AX_BOOST_SYSTEM
 
 # Checks for header files.
 AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h features.h inttypes.h limits.h stdint.h stdlib.h string.h sys/time.h unistd.h mutex.h malloc.h emmintrin.h byteswap.h bits/functexcept.h])
+AC_CHECK_HEADERS([fcntl.h features.h inttypes.h limits.h stdint.h stdlib.h string.h sys/time.h unistd.h mutex.h malloc.h emmintrin.h byteswap.h bits/functexcept.h bits/c++config.h])
 
 AC_CHECK_HEADER(double-conversion/double-conversion.h, [], [AC_MSG_ERROR(
                 [Couldn't find double-conversion.h, please download from \