From e0a255785f83e02da33f382be599e2c9a4d75e8c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 22 Feb 2014 22:39:43 +0000 Subject: [PATCH] Fix Unix build using clang with g++ 4.8 headers. Don't override HAVE_TR1_TYPE_TRAITS detected by configure with HAVE_TYPE_TRAITS detected by clang __has_include() as the latter is less reliable and can return true even when the header is not actually usable, as it happens with g++ 4.8 in non C++11 mode. Closes #15915. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75985 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/defs.h | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/include/wx/defs.h b/include/wx/defs.h index eba47f7b85..e921069595 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -351,30 +351,37 @@ typedef short int WXTYPE; #endif #if defined(__has_include) - #if !defined(HAVE_TYPE_TRAITS) && __has_include() - #define HAVE_TYPE_TRAITS + /* + Notice that we trust our configure tests more than __has_include(), + notably the latter can return true even if the header exists but isn't + actually usable, as it happens with in non C++11 mode. + So if configure already detected at least one working alternative, + just use it. + */ + #if !defined(HAVE_TYPE_TRAITS) && !defined(HAVE_TR1_TYPE_TRAITS) + #if __has_include() + #define HAVE_TYPE_TRAITS + #elif __has_include() + #define HAVE_TR1_TYPE_TRAITS + #endif #endif - #if !defined(HAVE_TR1_TYPE_TRAITS) && __has_include() - #define HAVE_TR1_TYPE_TRAITS + #if !defined(HAVE_STD_UNORDERED_MAP) && !defined(HAVE_TR1_UNORDERED_MAP) + #if __has_include() + #define HAVE_STD_UNORDERED_MAP + #elif __has_include() + #define HAVE_TR1_UNORDERED_MAP + #endif #endif - #if !defined(HAVE_STD_UNORDERED_MAP) && __has_include() - #define HAVE_STD_UNORDERED_MAP + #if !defined(HAVE_STD_UNORDERED_SET) && !defined(HAVE_TR1_UNORDERED_SET) + #if __has_include() + #define HAVE_STD_UNORDERED_SET + #elif __has_include() + #define HAVE_TR1_UNORDERED_SET + #endif #endif - - #if !defined(HAVE_TR1_UNORDERED_MAP) && __has_include() - #define HAVE_TR1_UNORDERED_MAP - #endif - - #if !defined(HAVE_STD_UNORDERED_SET) && __has_include() - #define HAVE_STD_UNORDERED_SET - #endif - - #if !defined(HAVE_TR1_UNORDERED_SET) && __has_include() - #define HAVE_TR1_UNORDERED_SET - #endif -#endif // defined(__has_include) +#endif /* defined(__has_include) */ /* provide replacement for C99 va_copy() if the compiler doesn't have it */