From f6dddd92282c9db684c0cf75fd0714624ec73f4e Mon Sep 17 00:00:00 2001 From: Martin Koegler Date: Sat, 30 Dec 2017 09:51:25 +0000 Subject: [PATCH] Use unordered_xxx classes detected by configure When using configure, use the same family of hash sets/maps when building wxWidgets and the applications using it as doing otherwise results in ABI incompatibility. --- include/wx/defs.h | 65 ++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/include/wx/defs.h b/include/wx/defs.h index 2c5cdeeeb6..5531948cef 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -378,40 +378,47 @@ typedef short int WXTYPE; #endif /* - Check for C++11 compilers, it is important to do it before the - __has_include() checks because at least g++ 4.9.2+ __has_include() returns - true for C++11 headers which can't be compiled in non-C++11 mode. - */ -#if __cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(10) - #ifndef HAVE_TYPE_TRAITS - #define HAVE_TYPE_TRAITS - #endif - #ifndef HAVE_STD_UNORDERED_MAP - #define HAVE_STD_UNORDERED_MAP - #endif - #ifndef HAVE_STD_UNORDERED_SET - #define HAVE_STD_UNORDERED_SET - #endif -#elif defined(__has_include) + If using configure, stick to the options detected by it even if different + compiler options could result in detecting something different here, as it + would cause ABI issues otherwise (see #18034). +*/ +#ifndef __WX_SETUP_H__ /* - We're in non-C++11 mode here, so only test for pre-C++11 headers. As - mentioned above, using __has_include() to test for C++11 would wrongly - detect them even though they can't be used in this case, don't do it. + Check for C++11 compilers, it is important to do it before the + __has_include() checks because at least g++ 4.9.2+ __has_include() returns + true for C++11 headers which can't be compiled in non-C++11 mode. */ - #if !defined(HAVE_TR1_TYPE_TRAITS) && __has_include() - #define HAVE_TR1_TYPE_TRAITS - #endif + #if __cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(10) + #ifndef HAVE_TYPE_TRAITS + #define HAVE_TYPE_TRAITS + #endif + #ifndef HAVE_STD_UNORDERED_MAP + #define HAVE_STD_UNORDERED_MAP + #endif + #ifndef HAVE_STD_UNORDERED_SET + #define HAVE_STD_UNORDERED_SET + #endif + #elif defined(__has_include) + /* + We're in non-C++11 mode here, so only test for pre-C++11 headers. As + mentioned above, using __has_include() to test for C++11 would wrongly + detect them even though they can't be used in this case, don't do it. + */ + #if !defined(HAVE_TR1_TYPE_TRAITS) && __has_include() + #define HAVE_TR1_TYPE_TRAITS + #endif - #if !defined(HAVE_TR1_UNORDERED_MAP) && __has_include() - #define HAVE_TR1_UNORDERED_MAP - #endif + #if !defined(HAVE_TR1_UNORDERED_MAP) && __has_include() + #define HAVE_TR1_UNORDERED_MAP + #endif - #if !defined(HAVE_TR1_UNORDERED_SET) && __has_include() - #define HAVE_TR1_UNORDERED_SET - #endif -#endif /* defined(__has_include) */ + #if !defined(HAVE_TR1_UNORDERED_SET) && __has_include() + #define HAVE_TR1_UNORDERED_SET + #endif + #endif /* defined(__has_include) */ -#endif /* __cplusplus */ + #endif /* __cplusplus */ +#endif /* __WX_SETUP_H__ */ /* provide replacement for C99 va_copy() if the compiler doesn't have it */