From 5ea84dd335cf19ca3771b3d8c9b2a9b2f4f31031 Mon Sep 17 00:00:00 2001 From: Peter Kasting Date: Thu, 27 Aug 2015 14:04:04 -0700 Subject: [PATCH 1/4] Refine check for unordered_{map|set} availability. It's not enough to check for C++11 language support, as it's possible for projects to enable C++11 language and library features independently (e.g. Chromium currently does this). Instead, explicitly check the library version to see if it is recent enough to include unordered_{map|set}. --- src/google/protobuf/stubs/hash.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h index 9a6b217adb..3ff72535a3 100755 --- a/src/google/protobuf/stubs/hash.h +++ b/src/google/protobuf/stubs/hash.h @@ -41,10 +41,10 @@ #define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1 #define GOOGLE_PROTOBUF_HAVE_HASH_SET 1 -// Use C++11 unordered_{map|set} if available. Otherwise, libc++ always support -// unordered_{map|set} -#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X) || \ - defined(_LIBCPP_VERSION) +// Use C++11 unordered_{map|set} if available. +#if ((__cplusplus >= 201103L) && \ + ((defined(__GLIBCXX__) && (__GLIBCXX__ > 20090421)) || \ + (defined(_LIBCPP_VERSION) && (_LIBCPP_STD_VER >= 11)))) # define GOOGLE_PROTOBUF_HAS_CXX11_HASH // For XCode >= 4.6: the compiler is clang with libc++. From 432771fa24c21ea43a76835a855030112fe33f73 Mon Sep 17 00:00:00 2001 From: Peter Kasting Date: Thu, 27 Aug 2015 14:48:52 -0700 Subject: [PATCH 2/4] Review comments --- src/google/protobuf/stubs/hash.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h index 3ff72535a3..2f01be5276 100755 --- a/src/google/protobuf/stubs/hash.h +++ b/src/google/protobuf/stubs/hash.h @@ -43,8 +43,7 @@ // Use C++11 unordered_{map|set} if available. #if ((__cplusplus >= 201103L) && \ - ((defined(__GLIBCXX__) && (__GLIBCXX__ > 20090421)) || \ - (defined(_LIBCPP_VERSION) && (_LIBCPP_STD_VER >= 11)))) + ((__GLIBCXX__ > 20090421) || (_LIBCPP_STD_VER >= 11))) # define GOOGLE_PROTOBUF_HAS_CXX11_HASH // For XCode >= 4.6: the compiler is clang with libc++. From a1be711e965f0f48faf84080319e97ddc6032243 Mon Sep 17 00:00:00 2001 From: Peter Kasting Date: Thu, 27 Aug 2015 19:59:06 -0700 Subject: [PATCH 3/4] Try modifying check in hopes of passing upstream build --- src/google/protobuf/stubs/hash.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h index 2f01be5276..f322d72291 100755 --- a/src/google/protobuf/stubs/hash.h +++ b/src/google/protobuf/stubs/hash.h @@ -42,8 +42,9 @@ #define GOOGLE_PROTOBUF_HAVE_HASH_SET 1 // Use C++11 unordered_{map|set} if available. -#if ((__cplusplus >= 201103L) && \ - ((__GLIBCXX__ > 20090421) || (_LIBCPP_STD_VER >= 11))) +#if ((_LIBCPP_STD_VER >= 11) || + (((__cplusplus >= 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X)) && + (__GLIBCXX__ > 20090421))) # define GOOGLE_PROTOBUF_HAS_CXX11_HASH // For XCode >= 4.6: the compiler is clang with libc++. From f5a332553e7947e6b1a5f9ddde97784d715dc685 Mon Sep 17 00:00:00 2001 From: Peter Kasting Date: Thu, 27 Aug 2015 20:12:56 -0700 Subject: [PATCH 4/4] It helps if you write macros correctly --- src/google/protobuf/stubs/hash.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h index f322d72291..c953e0e7a9 100755 --- a/src/google/protobuf/stubs/hash.h +++ b/src/google/protobuf/stubs/hash.h @@ -42,8 +42,8 @@ #define GOOGLE_PROTOBUF_HAVE_HASH_SET 1 // Use C++11 unordered_{map|set} if available. -#if ((_LIBCPP_STD_VER >= 11) || - (((__cplusplus >= 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X)) && +#if ((_LIBCPP_STD_VER >= 11) || \ + (((__cplusplus >= 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X)) && \ (__GLIBCXX__ > 20090421))) # define GOOGLE_PROTOBUF_HAS_CXX11_HASH