From 6bbfdb157eb3f44b9b26fb98d4bd667282ab308c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 7 Oct 2022 18:07:04 +0200 Subject: [PATCH] Check that C++11 is available and remove tests for it Don't bother checking for various C++11 features that are available in all C++11 compilers. Also assume that std::exception_ptr is available in all still supported MinGW versions and remove checks for it too (see #16634). Further simplifications remain possible, this is just the first step. --- include/wx/defs.h | 161 +++++++--------------------------- include/wx/math.h | 68 +------------- include/wx/meta/convertible.h | 8 -- include/wx/string.h | 4 - include/wx/unichar.h | 4 - include/wx/vector.h | 9 +- include/wx/wxcrtbase.h | 12 ++- src/common/appbase.cpp | 50 +---------- src/common/arrstr.cpp | 109 ----------------------- src/unix/threadpsx.cpp | 21 +---- tests/allheaders.cpp | 8 -- tests/controls/gridtest.cpp | 2 - tests/events/evthandler.cpp | 4 - tests/strings/vararg.cpp | 2 - tests/vectors/vectors.cpp | 3 - 15 files changed, 45 insertions(+), 420 deletions(-) diff --git a/include/wx/defs.h b/include/wx/defs.h index 4a6d0f7fb2..441baa5571 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -193,18 +193,9 @@ /* ============================================================================ */ /* ---------------------------------------------------------------------------- */ -/* compiler defects workarounds */ +/* C++ version check */ /* ---------------------------------------------------------------------------- */ -/* - Digital Unix C++ compiler only defines this symbol for .cxx and .hxx files, - so define it ourselves (newer versions do it for all files, though, and - don't allow it to be redefined) - */ -#if defined(__DECCXX) && !defined(__VMS) && !defined(__cplusplus) -#define __cplusplus -#endif /* __DECCXX */ - #if defined(_MSVC_LANG) /* We want to always use the really supported C++ standard when using MSVC @@ -219,6 +210,10 @@ #define wxCHECK_CXX_STD(ver) (_MSVC_LANG >= (ver)) #elif defined(__cplusplus) #define wxCHECK_CXX_STD(ver) (__cplusplus >= (ver)) + + #if !wxCHECK_CXX_STD(201103L) + #error "C++11 compiler is required to build wxWidgets." + #endif #else #define wxCHECK_CXX_STD(ver) 0 #endif @@ -256,62 +251,24 @@ typedef short int WXTYPE; /* wrap it in this guard, but such cases should still be relatively rare. */ #define wxUSE_NESTED_CLASSES 1 -/* This macro is obsolete, use the 'explicit' keyword in the new code. */ -#define wxEXPLICIT explicit - -/* check for override keyword support */ -#ifndef HAVE_OVERRIDE - #if __cplusplus >= 201103L - /* All C++11 compilers should have it. */ - #define HAVE_OVERRIDE - #elif wxCHECK_VISUALC_VERSION(11) - /* - VC++ supports override keyword since version 8 but doesn't define - __cplusplus as indicating C++11 support (at least up to and - including 12), so handle its case specially. - - Also note that while the keyword is supported, using it with - versions 8, 9 and 10 results in C4481 compiler warning ("nonstandard - extension used") and so we avoid using it there, you could disable - this warning and predefine HAVE_OVERRIDE if you don't care about it. - */ - #define HAVE_OVERRIDE - #elif WX_HAS_CLANG_FEATURE(cxx_override_control) - #define HAVE_OVERRIDE - #endif -#endif /* !HAVE_OVERRIDE */ - -#ifdef HAVE_OVERRIDE - #define wxOVERRIDE override -#else /* !HAVE_OVERRIDE */ - #define wxOVERRIDE -#endif /* HAVE_OVERRIDE */ - -/* same for more C++11 keywords which don't have such historic baggage as - override and so can be detected by just testing for C++11 support (which - still requires handling MSVS specially, unfortunately) */ -#if __cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(14) - #define wxHAS_MEMBER_DEFAULT - - #define wxHAS_NOEXCEPT - #define wxNOEXCEPT noexcept -#else - #define wxNOEXCEPT -#endif - /* - Support for nullptr is available since MSVS 2010, even though it doesn't - define __cplusplus as a C++11 compiler. + These macros are obsolete, use the corresponding C++ keywords directly in + the new code. */ -#if __cplusplus >= 201103 || wxCHECK_VISUALC_VERSION(10) - #define wxHAS_NULLPTR_T -#endif +#define wxEXPLICIT explicit +#define wxOVERRIDE override +#define wxNOEXCEPT noexcept + +/* More macros only remaining defined for compatibility */ +#define wxHAS_MEMBER_DEFAULT +#define wxHAS_NOEXCEPT +#define wxHAS_NULLPTR_T /* wxFALLTHROUGH is used to notate explicit fallthroughs in switch statements */ #if wxCHECK_CXX_STD(201703L) #define wxFALLTHROUGH [[fallthrough]] -#elif __cplusplus >= 201103L && defined(__has_warning) && WX_HAS_CLANG_FEATURE(cxx_attributes) +#elif defined(__has_warning) && WX_HAS_CLANG_FEATURE(cxx_attributes) #define wxFALLTHROUGH [[clang::fallthrough]] #elif wxCHECK_GCC_VERSION(7, 0) #define wxFALLTHROUGH __attribute__ ((fallthrough)) @@ -377,73 +334,24 @@ typedef short int WXTYPE; #define wxConstCast(obj, className) const_cast(obj) #ifndef HAVE_STD_WSTRING - #if __cplusplus >= 201103L - #define HAVE_STD_WSTRING - #elif defined(__VISUALC__) - #define HAVE_STD_WSTRING - #elif defined(__MINGW32__) - #define HAVE_STD_WSTRING - #endif + #define HAVE_STD_WSTRING #endif #ifndef HAVE_STD_STRING_COMPARE - #if __cplusplus >= 201103L - #define HAVE_STD_STRING_COMPARE - #elif defined(__VISUALC__) - #define HAVE_STD_STRING_COMPARE - #elif defined(__MINGW32__) || defined(__CYGWIN32__) - #define HAVE_STD_STRING_COMPARE - #endif + #define HAVE_STD_STRING_COMPARE #endif -#ifndef HAVE_TR1_TYPE_TRAITS - #if defined(__VISUALC__) && (_MSC_FULL_VER >= 150030729) - #define HAVE_TR1_TYPE_TRAITS - #endif +#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 -/* - 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__ - /* - 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) - /* - 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_SET) && __has_include() - #define HAVE_TR1_UNORDERED_SET - #endif - #endif /* defined(__has_include) */ - - #endif /* __cplusplus */ -#endif /* __WX_SETUP_H__ */ +#endif /* __cplusplus */ /* provide replacement for C99 va_copy() if the compiler doesn't have it */ @@ -3174,17 +3082,10 @@ typedef const void* WXWidget; /* macros to define a class without copy ctor nor assignment operator */ /* --------------------------------------------------------------------------- */ -#if defined(__cplusplus) && (__cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(14)) - #define wxMEMBER_DELETE = delete - #define wxDECLARE_DEFAULT_COPY_CTOR(classname) \ - public: \ - classname(const classname&) = default; -#else - #define wxMEMBER_DELETE - - // We can't do this without C++11 "= default". - #define wxDECLARE_DEFAULT_COPY_CTOR(classname) -#endif +#define wxMEMBER_DELETE = delete +#define wxDECLARE_DEFAULT_COPY_CTOR(classname) \ + public: \ + classname(const classname&) = default; #define wxDECLARE_NO_COPY_CLASS(classname) \ private: \ diff --git a/include/wx/math.h b/include/wx/math.h index e34521b1b0..e2d27bace1 100644 --- a/include/wx/math.h +++ b/include/wx/math.h @@ -55,56 +55,8 @@ #include -/* - Things are simple with C++11: we have everything we need in std. - Eventually we will only have this section and not the legacy stuff below. - */ -#if wxCHECK_CXX_STD(201103) - #define wxFinite(x) std::isfinite(x) - #define wxIsNaN(x) std::isnan(x) -#else /* C++98 */ - -#if defined(__VISUALC__) - #include - #define wxFinite(x) _finite(x) -#elif defined(__MINGW64_TOOLCHAIN__) || defined(__clang__) - /* - add more compilers with C99 support here: using C99 isfinite() is - preferable to using BSD-ish finite() - */ - #if defined(_GLIBCXX_CMATH) || defined(_LIBCPP_CMATH) - // these headers #undef isfinite - #define wxFinite(x) std::isfinite(x) - #else - #define wxFinite(x) isfinite(x) - #endif -#elif defined(wxNEEDS_STRICT_ANSI_WORKAROUNDS) - wxDECL_FOR_STRICT_MINGW32(int, _finite, (double)) - - #define wxFinite(x) _finite(x) -#elif ( defined(__GNUG__)||defined(__GNUWIN32__)|| \ - defined(__SGI_CC__)||defined(__SUNCC__)||defined(__XLC__)|| \ - defined(__HPUX__) ) && ( !defined(wxOSX_USE_IPHONE) || wxOSX_USE_IPHONE == 0 ) -#ifdef __SOLARIS__ -#include -#endif - #define wxFinite(x) finite(x) -#else - #define wxFinite(x) ((x) == (x)) -#endif - - -#if defined(__VISUALC__) - #define wxIsNaN(x) _isnan(x) -#elif defined(__GNUG__)||defined(__GNUWIN32__)|| \ - defined(__SGI_CC__)||defined(__SUNCC__)||defined(__XLC__)|| \ - defined(__HPUX__) - #define wxIsNaN(x) isnan(x) -#else - #define wxIsNaN(x) ((x) != (x)) -#endif - -#endif /* C++11/C++98 */ +#define wxFinite(x) std::isfinite(x) +#define wxIsNaN(x) std::isnan(x) #ifdef __INTELC__ @@ -139,13 +91,7 @@ inline int wxRound(double x) wxASSERT_MSG(x > double(INT_MIN) - 0.5 && x < double(INT_MAX) + 0.5, "argument out of supported range"); - #if wxCHECK_CXX_STD(201103) - return int(std::lround(x)); - #elif defined(HAVE_ROUND) || wxCHECK_VISUALC_VERSION(12) - return int(lround(x)); - #else - return int(x < 0 ? x - 0.5 : x + 0.5); - #endif + return int(std::lround(x)); } inline int wxRound(float x) @@ -153,13 +99,7 @@ inline int wxRound(float x) wxASSERT_MSG(x > float(INT_MIN) && x < float(INT_MAX), "argument out of supported range"); - #if wxCHECK_CXX_STD(201103) - return int(std::lround(x)); - #elif defined(HAVE_ROUND) || wxCHECK_VISUALC_VERSION(12) - return int(lroundf(x)); - #else - return int(x < 0.0f ? x - 0.5f : x + 0.5f); - #endif + return int(std::lround(x)); } inline int wxRound(long double x) { return wxRound(double(x)); } diff --git a/include/wx/meta/convertible.h b/include/wx/meta/convertible.h index a58d5f2370..dbda850928 100644 --- a/include/wx/meta/convertible.h +++ b/include/wx/meta/convertible.h @@ -44,15 +44,7 @@ struct wxIsPubliclyDerived { enum { -#if __cplusplus >= 201103 || (defined(_MSC_VER) && _MSC_VER >= 1600) - // If C++11 is available we use this, as on most compilers it's a - // built-in and will be evaluated at compile-time. value = std::is_base_of::value && std::is_convertible::value -#else - // When not using C++11, we fall back to wxConvertibleTo, which fails - // at compile-time if D doesn't publicly derive from B. - value = wxConvertibleTo::value -#endif }; }; diff --git a/include/wx/string.h b/include/wx/string.h index c7200ba957..6df615e1e9 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -4176,8 +4176,6 @@ wxDEFINE_ALL_COMPARISONS(const char *, const wxCStrData&, wxCMP_CHAR_CSTRDATA) // Implement hashing using C++11 std::hash<>. // ---------------------------------------------------------------------------- -#if __cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(10) - // Don't do this if ToStdWstring() is not available. We could work around it // but, presumably, if using std::wstring is undesirable, then so is using // std::hash<> anyhow. @@ -4199,8 +4197,6 @@ namespace std #endif // wxUSE_STD_STRING -#endif // C++11 - // --------------------------------------------------------------------------- // Implementation only from here until the end of file // --------------------------------------------------------------------------- diff --git a/include/wx/unichar.h b/include/wx/unichar.h index fc8d7d1493..efdf0951c9 100644 --- a/include/wx/unichar.h +++ b/include/wx/unichar.h @@ -363,8 +363,6 @@ void swap(wxUniCharRef& lhs, wxUniCharRef& rhs) } // namespace std -#if __cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(10) - // For std::iter_swap() to work with wxString::iterator, which uses // wxUniCharRef as its reference type, we need to ensure that swap() works with // wxUniCharRef objects by defining this overload. @@ -378,8 +376,6 @@ void swap(wxUniCharRef&& lhs, wxUniCharRef&& rhs) rhs = tmp; } -#endif // C++11 - // Comparison operators for the case when wxUniChar(Ref) is the second operand // implemented in terms of member comparison functions diff --git a/include/wx/vector.h b/include/wx/vector.h index 68150d3774..1a84851e29 100644 --- a/include/wx/vector.h +++ b/include/wx/vector.h @@ -703,17 +703,12 @@ inline bool wxVectorContains(const wxVector& v, const T& obj) #endif // wxUSE_STD_CONTAINERS/!wxUSE_STD_CONTAINERS -// Define vector::shrink_to_fit() equivalent which can be always used, even -// when using pre-C++11 std::vector. +// This is an obsolete function provided only for compatibility, just call +// shrink_to_fit() directly in the new code. template inline void wxShrinkToFit(wxVector& v) { -#if !wxUSE_STD_CONTAINERS || __cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(10) v.shrink_to_fit(); -#else - wxVector tmp(v); - v.swap(tmp); -#endif } #endif // _WX_VECTOR_H_ diff --git a/include/wx/wxcrtbase.h b/include/wx/wxcrtbase.h index 7887324206..4a3c1156ae 100644 --- a/include/wx/wxcrtbase.h +++ b/include/wx/wxcrtbase.h @@ -180,13 +180,11 @@ extern unsigned long android_wcstoul(const wchar_t *nptr, wchar_t **endptr, int #define wxCRT_StrtoullW _wcstoui64 #else /* Both of these functions are implemented in C++11 compilers */ - #if wxCHECK_CXX_STD(201103L) - #ifndef HAVE_STRTOULL - #define HAVE_STRTOULL - #endif - #ifndef HAVE_WCSTOULL - #define HAVE_WCSTOULL - #endif + #ifndef HAVE_STRTOULL + #define HAVE_STRTOULL + #endif + #ifndef HAVE_WCSTOULL + #define HAVE_WCSTOULL #endif #ifdef HAVE_STRTOULL diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index 9bc3cce719..34c8e6b7b3 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -45,42 +45,10 @@ #include "wx/stdpaths.h" #if wxUSE_EXCEPTIONS - // Do we have a C++ compiler with enough C++11 support for - // std::exception_ptr and functions working with it? - #if __cplusplus >= 201103L - // Any conforming C++11 compiler should have it, but g++ implementation - // of exception handling depends on the availability of the atomic int - // operations apparently, so all known version of g++ with C++11 support - // (4.7..4.9) fail to provide exception_ptr if the symbol below is not - // set to 2 (meaning "always available"), which is notably the case for - // MinGW-w64 without -march=486 switch, see #16634. - #ifdef __GNUC__ - // This symbol is always defined in the known g++ version, so - // assume that if it isn't defined, things changed for the better - // and optimistically suppose that exception_ptr is available. - #if !defined(__GCC_ATOMIC_INT_LOCK_FREE) \ - || __GCC_ATOMIC_INT_LOCK_FREE > 1 - #define HAS_EXCEPTION_PTR - #endif - #else - #define HAS_EXCEPTION_PTR - #endif - #elif wxCHECK_VISUALC_VERSION(11) - // VC++ supports it since version 10, even though it doesn't define - // __cplusplus to C++11 value, but MSVC 2010 doesn't have a way to test - // whether exception_ptr is valid, so we'd need to use a separate bool - // flag for it if we wanted to make it work. For now just settle for - // only using exception_ptr for VC11 and later. - #define HAS_EXCEPTION_PTR - #endif - - #ifdef HAS_EXCEPTION_PTR - #include // for std::current_exception() - #include // for std::swap() - #endif + #include // for std::current_exception() + #include // for std::swap() #if wxUSE_STL - #include #include #endif #endif // wxUSE_EXCEPTIONS @@ -716,7 +684,6 @@ bool wxAppConsoleBase::OnExceptionInMainLoop() throw; } -#ifdef HAS_EXCEPTION_PTR static std::exception_ptr gs_storedException; bool wxAppConsoleBase::StoreCurrentException() @@ -746,19 +713,6 @@ void wxAppConsoleBase::RethrowStoredException() } } -#else // !HAS_EXCEPTION_PTR - -bool wxAppConsoleBase::StoreCurrentException() -{ - return false; -} - -void wxAppConsoleBase::RethrowStoredException() -{ -} - -#endif // HAS_EXCEPTION_PTR/!HAS_EXCEPTION_PTR - #endif // wxUSE_EXCEPTIONS // ---------------------------------------------------------------------------- diff --git a/src/common/arrstr.cpp b/src/common/arrstr.cpp index 4efeab8c46..ccfd669910 100644 --- a/src/common/arrstr.cpp +++ b/src/common/arrstr.cpp @@ -57,8 +57,6 @@ wxArrayString::wxArrayString(size_t sz, const wxString* a) #include "wx/arrstr.h" -#if __cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(14) - int wxArrayString::Index(const wxString& str, bool bCase, bool bFromEnd) const { int n = 0; @@ -82,116 +80,13 @@ int wxArrayString::Index(const wxString& str, bool bCase, bool bFromEnd) const return wxNOT_FOUND; } -#else // C++98 version - -#include "wx/beforestd.h" -#include -#include "wx/afterstd.h" - -// some compilers (Sun CC being the only known example) distinguish between -// extern "C" functions and the functions with C++ linkage and ptr_fun and -// wxStringCompareLess can't take wxStrcmp/wxStricmp directly as arguments in -// this case, we need the wrappers below to make this work -struct wxStringCmp -{ - typedef wxString first_argument_type; - typedef wxString second_argument_type; - typedef int result_type; - - int operator()(const wxString& s1, const wxString& s2) const - { - return s1.compare(s2); - } -}; - -struct wxStringCmpNoCase -{ - typedef wxString first_argument_type; - typedef wxString second_argument_type; - typedef int result_type; - - int operator()(const wxString& s1, const wxString& s2) const - { - return s1.CmpNoCase(s2); - } -}; - -int wxArrayString::Index(const wxString& str, bool bCase, bool bFromEnd) const -{ - if (!bFromEnd) - { - wxArrayString::const_iterator it; - - if (bCase) - { - it = std::find_if(begin(), end(), - std::not1( - std::bind2nd( - wxStringCmp(), str))); - } - else // !bCase - { - it = std::find_if(begin(), end(), - std::not1( - std::bind2nd( - wxStringCmpNoCase(), str))); - } - - return it == end() ? wxNOT_FOUND : it - begin(); - } - else // bFromEnd - { - wxArrayString::const_reverse_iterator it; - - if (bCase) - { - it = std::find_if(rbegin(), rend(), - std::not1( - std::bind2nd( - wxStringCmp(), str))); - } - else // !bCase - { - it = std::find_if(rbegin(), rend(), - std::not1( - std::bind2nd( - wxStringCmpNoCase(), str))); - } - - return it == rend() ? wxNOT_FOUND : it.base()-1 - begin(); - } -} - -template -class wxStringCompareLess -{ -public: - wxStringCompareLess(F f) : m_f(f) { } - bool operator()(const wxString& s1, const wxString& s2) - { return m_f(s1, s2) < 0; } -private: - F m_f; -}; - -template -wxStringCompareLess wxStringCompare(F f) -{ - return wxStringCompareLess(f); -} - -#endif // C++11/C++98 - void wxArrayString::Sort(CompareFunction function) { std::sort(begin(), end(), -#if __cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(14) [function](const wxString& s1, const wxString& s2) { return function(s1, s2) < 0; } -#else // C++98 version - wxStringCompare(function) -#endif // C++11/C++98 ); } @@ -217,14 +112,10 @@ int wxSortedArrayString::Index(const wxString& str, SCMPFUNC function = GetCompareFunction(); wxSortedArrayString::const_iterator it = std::lower_bound(begin(), end(), str, -#if __cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(14) [function](const wxString& s1, const wxString& s2) { return function(s1, s2) < 0; } -#else // C++98 version - wxStringCompare(function) -#endif // C++11/C++98 ); if ( it == end() || str.Cmp(*it) != 0 ) diff --git a/src/unix/threadpsx.cpp b/src/unix/threadpsx.cpp index 7f920f76e2..cf828d65b8 100644 --- a/src/unix/threadpsx.cpp +++ b/src/unix/threadpsx.cpp @@ -81,14 +81,7 @@ #endif #endif -// We don't provide wxAtomicLong and it doesn't seem really useful to add it -// now when C++11 is widely available, so just use the standard C++11 type if -// possible and live without it otherwise. -#if __cplusplus >= 201103L - #include - - #define HAS_ATOMIC_ULONG -#endif // C++11 +#include #define THR_ID_CAST(id) (reinterpret_cast(id)) #define THR_ID(thr) THR_ID_CAST((thr)->GetId()) @@ -215,9 +208,7 @@ private: // This member must be atomic as it's written and read from different // threads. If atomic operations are not available, we won't detect mutex // deadlocks at wx level. -#ifdef HAS_ATOMIC_ULONG std::atomic_ulong m_owningThread; -#endif // wxConditionInternal uses our m_mutex friend class wxConditionInternal; @@ -233,9 +224,7 @@ extern "C" int pthread_mutexattr_settype(pthread_mutexattr_t *, int); wxMutexInternal::wxMutexInternal(wxMutexType mutexType) { m_type = mutexType; -#ifdef HAS_ATOMIC_ULONG m_owningThread = 0; -#endif int err; switch ( mutexType ) @@ -297,10 +286,8 @@ wxMutexInternal::~wxMutexInternal() wxMutexError wxMutexInternal::Lock() { -#ifdef HAS_ATOMIC_ULONG if ( m_type == wxMUTEX_DEFAULT && m_owningThread == wxThread::GetCurrentId() ) return wxMUTEX_DEAD_LOCK; -#endif // HAS_ATOMIC_ULONG return HandleLockResult(pthread_mutex_lock(&m_mutex)); } @@ -375,10 +362,8 @@ wxMutexError wxMutexInternal::HandleLockResult(int err) return wxMUTEX_TIMEOUT; case 0: -#ifdef HAS_ATOMIC_ULONG if (m_type == wxMUTEX_DEFAULT) m_owningThread = wxThread::GetCurrentId(); -#endif // HAS_ATOMIC_ULONG return wxMUTEX_NO_ERROR; default: @@ -404,10 +389,8 @@ wxMutexError wxMutexInternal::TryLock() break; case 0: -#ifdef HAS_ATOMIC_ULONG if (m_type == wxMUTEX_DEFAULT) m_owningThread = wxThread::GetCurrentId(); -#endif // HAS_ATOMIC_ULONG return wxMUTEX_NO_ERROR; default: @@ -419,9 +402,7 @@ wxMutexError wxMutexInternal::TryLock() wxMutexError wxMutexInternal::Unlock() { -#ifdef HAS_ATOMIC_ULONG m_owningThread = 0; -#endif // HAS_ATOMIC_ULONG int err = pthread_mutex_unlock(&m_mutex); switch ( err ) diff --git a/tests/allheaders.cpp b/tests/allheaders.cpp index 73e460703c..12b938b1c3 100644 --- a/tests/allheaders.cpp +++ b/tests/allheaders.cpp @@ -389,14 +389,6 @@ CLANG_TURN_ON(all) CLANG_TURN_ON(extra) CLANG_TURN_ON(pedantic) - - // We use long long, variadic macros and empty macro arguments (which are a - // C99 extension) even in C++98 builds. - #if __cplusplus < 201103L - CLANG_TURN_OFF(c++11-long-long) - CLANG_TURN_OFF(variadic-macros) - CLANG_TURN_OFF(c99-extensions) - #endif #endif // clang diff --git a/tests/controls/gridtest.cpp b/tests/controls/gridtest.cpp index 447178b955..63004c3119 100644 --- a/tests/controls/gridtest.cpp +++ b/tests/controls/gridtest.cpp @@ -849,7 +849,6 @@ TEST_CASE_METHOD(GridTestCase, "Grid::SelectionRange", "[grid]") REQUIRE( sel.begin() != sel.end() ); CHECK( *sel.begin() == wxGridBlockCoords(1, 0, 3, 1) ); -#if __cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(11) m_grid->SelectBlock(4, 0, 7, 1, true); int index = 0; for ( const wxGridBlockCoords& block : m_grid->GetSelectedBlocks() ) @@ -868,7 +867,6 @@ TEST_CASE_METHOD(GridTestCase, "Grid::SelectionRange", "[grid]") } ++index; } -#endif } TEST_CASE_METHOD(GridTestCase, "Grid::SelectEmptyGrid", "[grid]") diff --git a/tests/events/evthandler.cpp b/tests/events/evthandler.cpp index 65616d4e48..ffdbe7b1b2 100644 --- a/tests/events/evthandler.cpp +++ b/tests/events/evthandler.cpp @@ -510,9 +510,6 @@ TEST_CASE("Event::UnbindFromHandler", "[event][bind][unbind]") // This is a compilation-time-only test: just check that a class inheriting // from wxEvtHandler non-publicly can use Bind() with its method, this used to // result in compilation errors. -// Note that this test will work only on C++11 compilers, so we test this only -// for such compilers. -#if __cplusplus >= 201103 || wxCHECK_VISUALC_VERSION(14) class HandlerNonPublic : protected wxEvtHandler { public: @@ -523,7 +520,6 @@ public: void OnIdle(wxIdleEvent&) { } }; -#endif // C++11 // Another compilation-time-only test, but this one checking that these event // objects can't be created from outside of the library. diff --git a/tests/strings/vararg.cpp b/tests/strings/vararg.cpp index 1f3beccf71..3b8a7ef6b8 100644 --- a/tests/strings/vararg.cpp +++ b/tests/strings/vararg.cpp @@ -202,12 +202,10 @@ TEST_CASE("ArgsValidation", "[wxString][vararg][error]") wxString::Format("a string(%s,%s), ptr %p, int %i", wxString(), "foo", "char* as pointer", 1); -#if __cplusplus >= 201103 || wxCHECK_VISUALC_VERSION(10) // Unfortunately we can't check the result as different standard libraries // implementations format it in different ways, so just check that it // compiles. wxString::Format("null pointer is %p", nullptr); -#endif // Microsoft has helpfully disabled support for "%n" in their CRT by // default starting from VC8 and somehow even calling diff --git a/tests/vectors/vectors.cpp b/tests/vectors/vectors.cpp index 166133718f..7b41c131c8 100644 --- a/tests/vectors/vectors.cpp +++ b/tests/vectors/vectors.cpp @@ -375,8 +375,6 @@ TEST_CASE("wxVector::capacity", "[vector][capacity][shrink_to_fit]") CHECK( v.capacity() >= 1 ); #endif - // There is no shrink_to_fit() in STL build when not using C++11. -#if !wxUSE_STD_CONTAINERS || __cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(10) v.shrink_to_fit(); CHECK( v.capacity() == 1 ); @@ -385,5 +383,4 @@ TEST_CASE("wxVector::capacity", "[vector][capacity][shrink_to_fit]") v.shrink_to_fit(); CHECK( v.capacity() == 0 ); -#endif }