diff --git a/include/wx/compiler.h b/include/wx/compiler.h index 5ad4df8561..de67477f84 100644 --- a/include/wx/compiler.h +++ b/include/wx/compiler.h @@ -139,15 +139,11 @@ maj.min */ -/* Check for Mingw runtime version: */ +/* + Define Mingw identification symbols, wxCHECK_MINGW32_VERSION() is defined in + wx/msw/gccpriv.h which is included later, see comments there. + */ #ifdef __MINGW32__ - /* Include the header defining __MINGW32_{MAJ,MIN}OR_VERSION */ - #include <_mingw.h> - - #define wxCHECK_MINGW32_VERSION( major, minor ) \ - ( ( ( __MINGW32_MAJOR_VERSION > (major) ) \ - || ( __MINGW32_MAJOR_VERSION == (major) && __MINGW32_MINOR_VERSION >= (minor) ) ) ) - /* MinGW-w64 project provides compilers for both Win32 and Win64 but only defines the same __MINGW32__ symbol for the former as MinGW32 toolchain @@ -169,8 +165,6 @@ # define __MINGW32_TOOLCHAIN__ # endif # endif -#else - #define wxCHECK_MINGW32_VERSION( major, minor ) (0) #endif #endif // _WX_COMPILER_H_ diff --git a/include/wx/msw/gccpriv.h b/include/wx/msw/gccpriv.h index 31453015b2..4bebc12090 100644 --- a/include/wx/msw/gccpriv.h +++ b/include/wx/msw/gccpriv.h @@ -17,8 +17,29 @@ #define __GNUWIN32__ #endif -#if defined(__MINGW32__) && ( ( __GNUC__ > 2 ) || ( ( __GNUC__ == 2 ) && ( __GNUC_MINOR__ >= 95 ) ) ) +#if defined(__MINGW32__) + /* + Include the header defining __MINGW32_{MAJ,MIN}OR_VERSION but check + that UNICODE or _UNICODE is already defined, as _mingw.h relies on them + being set and we'd get weird compilation errors later if it is included + without them being defined, better give a clearer error right now. + */ + #if !defined(UNICODE) + #ifndef wxUSE_UNICODE + #error "wxUSE_UNICODE must be defined before including this header." + #endif + #if wxUSE_UNICODE + #error "UNICODE must be defined before including this header." + #endif + #endif + #include <_mingw.h> + + #define wxCHECK_MINGW32_VERSION( major, minor ) \ + ( ( ( __MINGW32_MAJOR_VERSION > (major) ) \ + || ( __MINGW32_MAJOR_VERSION == (major) && __MINGW32_MINOR_VERSION >= (minor) ) ) ) +#else + #define wxCHECK_MINGW32_VERSION( major, minor ) (0) #endif #if defined( __MINGW32__ ) && !defined(__WINE__) && !defined( HAVE_W32API_H ) diff --git a/include/wx/platform.h b/include/wx/platform.h index 97c669f7a4..1b5a4b7ffa 100644 --- a/include/wx/platform.h +++ b/include/wx/platform.h @@ -456,6 +456,10 @@ #define wxNEEDS_CHARPP #endif +/* + Note that wx/msw/gccpriv.h must be included after defining UNICODE and + _UNICODE macros as it includes _mingw.h which relies on them being set. + */ #if ( defined( __GNUWIN32__ ) || defined( __MINGW32__ ) || \ ( defined( __CYGWIN__ ) && defined( __WINDOWS__ ) ) || \ wxCHECK_WATCOM_VERSION(1,0) ) && \ @@ -467,6 +471,8 @@ #else # undef wxCHECK_W32API_VERSION # define wxCHECK_W32API_VERSION(maj, min) (0) +# undef wxCHECK_MINGW32_VERSION +# define wxCHECK_MINGW32_VERSION( major, minor ) (0) #endif