gccpriv.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. Name: wx/msw/gccpriv.h
  3. Purpose: MinGW/Cygwin definitions
  4. Author: Vadim Zeitlin
  5. Modified by:
  6. Created:
  7. Copyright: (c) Vadim Zeitlin
  8. Licence: wxWindows Licence
  9. */
  10. /* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
  11. #ifndef _WX_MSW_GCCPRIV_H_
  12. #define _WX_MSW_GCCPRIV_H_
  13. #if defined(__MINGW32__) && !defined(__GNUWIN32__)
  14. #define __GNUWIN32__
  15. #endif
  16. #if defined(__MINGW32__)
  17. /*
  18. Include the header defining __MINGW32_{MAJ,MIN}OR_VERSION but check
  19. that UNICODE or _UNICODE is already defined, as _mingw.h relies on them
  20. being set and we'd get weird compilation errors later if it is included
  21. without them being defined, better give a clearer error right now.
  22. */
  23. #if !defined(UNICODE)
  24. #ifndef wxUSE_UNICODE
  25. #error "wxUSE_UNICODE must be defined before including this header."
  26. #endif
  27. #if wxUSE_UNICODE
  28. #error "UNICODE must be defined before including this header."
  29. #endif
  30. #endif
  31. #include <_mingw.h>
  32. /*
  33. MinGW-w64 project provides compilers for both Win32 and Win64 but only
  34. defines the same __MINGW32__ symbol for the former as MinGW32 toolchain
  35. which is quite different (notably doesn't provide many SDK headers that
  36. MinGW-w64 does include). So we define a separate symbol which, unlike
  37. the predefined __MINGW64__, can be used to detect this toolchain in
  38. both 32 and 64 bit builds.
  39. And define __MINGW32_TOOLCHAIN__ for consistency and also because it's
  40. convenient as we often want to have some workarounds only for the (old)
  41. MinGW32 but not (newer) MinGW-w64, which still predefines __MINGW32__.
  42. */
  43. #ifdef __MINGW64_VERSION_MAJOR
  44. #ifndef __MINGW64_TOOLCHAIN__
  45. #define __MINGW64_TOOLCHAIN__
  46. #endif
  47. #else
  48. #ifndef __MINGW32_TOOLCHAIN__
  49. #define __MINGW32_TOOLCHAIN__
  50. #endif
  51. #endif
  52. #define wxCHECK_MINGW32_VERSION( major, minor ) \
  53. ( ( ( __MINGW32_MAJOR_VERSION > (major) ) \
  54. || ( __MINGW32_MAJOR_VERSION == (major) && __MINGW32_MINOR_VERSION >= (minor) ) ) )
  55. #else
  56. #define wxCHECK_MINGW32_VERSION( major, minor ) (0)
  57. #endif
  58. #if defined( __MINGW32__ ) && !defined(__WINE__) && !defined( HAVE_W32API_H )
  59. #if __MINGW32_MAJOR_VERSION >= 1
  60. #define HAVE_W32API_H
  61. #endif
  62. #elif defined( __CYGWIN__ ) && !defined( HAVE_W32API_H )
  63. #if ( __GNUC__ > 2 )
  64. #define HAVE_W32API_H
  65. #endif
  66. #endif
  67. #if wxCHECK_WATCOM_VERSION(1,0)
  68. #define HAVE_W32API_H
  69. #endif
  70. /* check for MinGW/Cygwin w32api version ( releases >= 0.5, only ) */
  71. #if defined( HAVE_W32API_H )
  72. #include <w32api.h>
  73. #endif
  74. /* Watcom can't handle defined(xxx) here: */
  75. #if defined(__W32API_MAJOR_VERSION) && defined(__W32API_MINOR_VERSION)
  76. #define wxCHECK_W32API_VERSION( major, minor ) \
  77. ( ( ( __W32API_MAJOR_VERSION > (major) ) \
  78. || ( __W32API_MAJOR_VERSION == (major) && __W32API_MINOR_VERSION >= (minor) ) ) )
  79. #else
  80. #define wxCHECK_W32API_VERSION( major, minor ) (0)
  81. #endif
  82. /* Cygwin / Mingw32 with gcc >= 2.95 use new windows headers which
  83. are more ms-like (header author is Anders Norlander, hence the name) */
  84. #if (defined(__MINGW32__) || defined(__CYGWIN__) || defined(__WINE__)) && ((__GNUC__>2) || ((__GNUC__==2) && (__GNUC_MINOR__>=95)))
  85. #ifndef wxUSE_NORLANDER_HEADERS
  86. #define wxUSE_NORLANDER_HEADERS 1
  87. #endif
  88. #else
  89. #ifndef wxUSE_NORLANDER_HEADERS
  90. #define wxUSE_NORLANDER_HEADERS 0
  91. #endif
  92. #endif
  93. /* "old" GNUWIN32 is the one without Norlander's headers: it lacks the
  94. standard Win32 headers and we define the used stuff ourselves for it
  95. in wx/msw/gnuwin32/extra.h */
  96. #if defined(__GNUC__) && !wxUSE_NORLANDER_HEADERS
  97. #define __GNUWIN32_OLD__
  98. #endif
  99. /* Cygwin 1.0 */
  100. #if defined(__CYGWIN__) && ((__GNUC__==2) && (__GNUC_MINOR__==9))
  101. #define __CYGWIN10__
  102. #endif
  103. /* Mingw runtime 1.0-20010604 has some missing _tXXXX functions,
  104. so let's define them ourselves: */
  105. #if defined(__GNUWIN32__) && wxCHECK_W32API_VERSION( 1, 0 ) \
  106. && !wxCHECK_W32API_VERSION( 1, 1 )
  107. #ifndef _tsetlocale
  108. #if wxUSE_UNICODE
  109. #define _tsetlocale _wsetlocale
  110. #else
  111. #define _tsetlocale setlocale
  112. #endif
  113. #endif
  114. #ifndef _tgetenv
  115. #if wxUSE_UNICODE
  116. #define _tgetenv _wgetenv
  117. #else
  118. #define _tgetenv getenv
  119. #endif
  120. #endif
  121. #ifndef _tfopen
  122. #if wxUSE_UNICODE
  123. #define _tfopen _wfopen
  124. #else
  125. #define _tfopen fopen
  126. #endif
  127. #endif
  128. #endif
  129. /* current (= before mingw-runtime 3.3) mingw32 headers forget to
  130. define _puttchar, this will probably be fixed in the next versions but
  131. for now do it ourselves
  132. */
  133. #if defined( __MINGW32__ ) && \
  134. !wxCHECK_MINGW32_VERSION(3,3) && !defined( _puttchar )
  135. #ifdef wxUSE_UNICODE
  136. #define _puttchar putwchar
  137. #else
  138. #define _puttchar puttchar
  139. #endif
  140. #endif
  141. #endif
  142. /* _WX_MSW_GCCPRIV_H_ */