From: Elizabeth Smith Date: Wed, 23 Apr 2014 20:09:53 +0000 (-0700) Subject: Better detection X-Git-Tag: v0.22.0~583 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=0630bb0f685024915a8b3c7dd11ec43b7ac7cdd9;p=folly.git Better detection 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 --- diff --git a/folly/FBString.h b/folly/FBString.h index 40e19b53..dd5b0642 100644 --- a/folly/FBString.h +++ b/folly/FBString.h @@ -63,8 +63,10 @@ #include #include -// 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 diff --git a/folly/Range.h b/folly/Range.h index fc238b3e..620316ee 100644 --- a/folly/Range.h +++ b/folly/Range.h @@ -31,8 +31,8 @@ #include #include -// 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 diff --git a/folly/Traits.h b/folly/Traits.h index 9f90fa56..bfdf8c70 100644 --- a/folly/Traits.h +++ b/folly/Traits.h @@ -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 diff --git a/folly/configure.ac b/folly/configure.ac index 4e9c8041..a93c1ffd 100644 --- a/folly/configure.ac +++ b/folly/configure.ac @@ -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 \