diff --git a/include/wx/msw/gccpriv.h b/include/wx/msw/gccpriv.h index 45b2c758f1..8fd4490b73 100644 --- a/include/wx/msw/gccpriv.h +++ b/include/wx/msw/gccpriv.h @@ -149,26 +149,34 @@ the new C++11 features and not disable the use of POSIX functions, we just manually declare the functions we need in this case if necessary. */ -#if defined(__MINGW32_TOOLCHAIN__) && defined(__STRICT_ANSI__) - #define wxNEEDS_STRICT_ANSI_WORKAROUNDS - +#ifdef __MINGW32_TOOLCHAIN__ /* This macro is somewhat unusual as it takes the list of parameters inside parentheses and includes semicolon inside it as putting the semicolon outside wouldn't do the right thing when this macro is empty. */ - #define wxDECL_FOR_STRICT_MINGW32(rettype, func, params) \ + #define wxDECL_FOR_MINGW32_ALWAYS(rettype, func, params) \ extern "C" _CRTIMP rettype __cdecl __MINGW_NOTHROW func params ; - /* - There is a bug resulting in a compilation error in MinGW standard - math.h header, see https://sourceforge.net/p/mingw/bugs/2250/, work - around it here because math.h is also included from several other - standard headers (e.g. ) and we don't want to duplicate this - hack everywhere this happens. - */ - wxDECL_FOR_STRICT_MINGW32(double, _hypot, (double, double)) + #ifdef __STRICT_ANSI__ + #define wxNEEDS_STRICT_ANSI_WORKAROUNDS + + #define wxDECL_FOR_STRICT_MINGW32(rettype, func, params) \ + wxDECL_FOR_MINGW32_ALWAYS(rettype, func, params) + + /* + There is a bug resulting in a compilation error in MinGW standard + math.h header, see https://sourceforge.net/p/mingw/bugs/2250/, work + around it here because math.h is also included from several other + standard headers (e.g. ) and we don't want to duplicate this + hack everywhere this happens. + */ + wxDECL_FOR_STRICT_MINGW32(double, _hypot, (double, double)) + #else + #define wxDECL_FOR_STRICT_MINGW32(rettype, func, params) + #endif #else + #define wxDECL_FOR_MINGW32_ALWAYS(rettype, func, params) #define wxDECL_FOR_STRICT_MINGW32(rettype, func, params) #endif diff --git a/include/wx/platform.h b/include/wx/platform.h index b490d52a96..122ffabef4 100644 --- a/include/wx/platform.h +++ b/include/wx/platform.h @@ -358,6 +358,7 @@ # define wxCHECK_W32API_VERSION(maj, min) (0) # undef wxCHECK_MINGW32_VERSION # define wxCHECK_MINGW32_VERSION( major, minor ) (0) +# define wxDECL_FOR_MINGW32_ALWAYS(rettype, func, params) # define wxDECL_FOR_STRICT_MINGW32(rettype, func, params) #endif diff --git a/include/wx/wxcrtbase.h b/include/wx/wxcrtbase.h index 9b84d737bd..77c93c8e0b 100644 --- a/include/wx/wxcrtbase.h +++ b/include/wx/wxcrtbase.h @@ -230,8 +230,15 @@ extern unsigned long android_wcstoul(const wchar_t *nptr, wchar_t **endptr, int #define wxCRT_StricmpA stricmp #define wxCRT_StrnicmpA strnicmp #elif defined(__VISUALC__) || defined(__MINGW32__) - wxDECL_FOR_STRICT_MINGW32(int, _stricmp, (const char*, const char*)) - wxDECL_FOR_STRICT_MINGW32(int, _strnicmp, (const char*, const char*, size_t)) + /* + Due to MinGW 5.3 bug (https://sourceforge.net/p/mingw/bugs/2322/), + _stricmp() and _strnicmp() are not declared in its standard headers + when compiling without optimizations. Work around this by always + declaring them ourselves (notice that if/when this bug were fixed, we'd + still need to use wxDECL_FOR_STRICT_MINGW32() for them here. + */ + wxDECL_FOR_MINGW32_ALWAYS(int, _stricmp, (const char*, const char*)) + wxDECL_FOR_MINGW32_ALWAYS(int, _strnicmp, (const char*, const char*, size_t)) #define wxCRT_StricmpA _stricmp #define wxCRT_StrnicmpA _strnicmp