compiler.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Name: wx/compiler.h
  3. * Purpose: Compiler-specific macro definitions.
  4. * Author: Vadim Zeitlin
  5. * Created: 2013-07-13 (extracted from wx/platform.h)
  6. * Copyright: (c) 1997-2013 Vadim Zeitlin <vadim@wxwidgets.org>
  7. * Licence: wxWindows licence
  8. */
  9. /* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
  10. #ifndef _WX_COMPILER_H_
  11. #define _WX_COMPILER_H_
  12. /*
  13. Compiler detection and related helpers.
  14. */
  15. /*
  16. Notice that Intel compiler can be used as Microsoft Visual C++ add-on and
  17. so we should define both __INTELC__ and __VISUALC__ for it.
  18. */
  19. #ifdef __INTEL_COMPILER
  20. # define __INTELC__
  21. #endif
  22. #if defined(_MSC_VER)
  23. /*
  24. define another standard symbol for Microsoft Visual C++: the standard
  25. one (_MSC_VER) is also defined by some other compilers.
  26. */
  27. # define __VISUALC__ _MSC_VER
  28. /*
  29. define special symbols for different VC version instead of writing tests
  30. for magic numbers such as 1200, 1300 &c repeatedly
  31. */
  32. #if __VISUALC__ < 1100
  33. # error "This Visual C++ version is too old and not supported any longer."
  34. #elif __VISUALC__ < 1200
  35. # define __VISUALC5__
  36. #elif __VISUALC__ < 1300
  37. # define __VISUALC6__
  38. #elif __VISUALC__ < 1400
  39. # define __VISUALC7__
  40. #elif __VISUALC__ < 1500
  41. # define __VISUALC8__
  42. #elif __VISUALC__ < 1600
  43. # define __VISUALC9__
  44. #elif __VISUALC__ < 1700
  45. # define __VISUALC10__
  46. #elif __VISUALC__ < 1800
  47. # define __VISUALC11__
  48. #elif __VISUALC__ < 1900
  49. # define __VISUALC12__
  50. #else
  51. # pragma message("Please update wx/compiler.h to recognize this VC++ version")
  52. #endif
  53. #elif defined(__BCPLUSPLUS__) && !defined(__BORLANDC__)
  54. # define __BORLANDC__
  55. #elif defined(__WATCOMC__)
  56. #elif defined(__SC__)
  57. # define __SYMANTECC__
  58. #elif defined(__SUNPRO_CC)
  59. # ifndef __SUNCC__
  60. # define __SUNCC__ __SUNPRO_CC
  61. # endif /* Sun CC */
  62. #elif defined(__SC__)
  63. # ifdef __DMC__
  64. # define __DIGITALMARS__
  65. # else
  66. # define __SYMANTEC__
  67. # endif
  68. #endif /* compiler */
  69. /*
  70. Macros for checking compiler version.
  71. */
  72. /*
  73. This macro can be used to test the gcc version and can be used like this:
  74. # if wxCHECK_GCC_VERSION(3, 1)
  75. ... we have gcc 3.1 or later ...
  76. # else
  77. ... no gcc at all or gcc < 3.1 ...
  78. # endif
  79. */
  80. #if defined(__GNUC__) && defined(__GNUC_MINOR__)
  81. #define wxCHECK_GCC_VERSION( major, minor ) \
  82. ( ( __GNUC__ > (major) ) \
  83. || ( __GNUC__ == (major) && __GNUC_MINOR__ >= (minor) ) )
  84. #else
  85. #define wxCHECK_GCC_VERSION( major, minor ) 0
  86. #endif
  87. /*
  88. This macro can be used to test the Visual C++ version.
  89. */
  90. #ifndef __VISUALC__
  91. # define wxVISUALC_VERSION(major) 0
  92. # define wxCHECK_VISUALC_VERSION(major) 0
  93. #else
  94. # define wxVISUALC_VERSION(major) ( (6 + major) * 100 )
  95. # define wxCHECK_VISUALC_VERSION(major) ( __VISUALC__ >= wxVISUALC_VERSION(major) )
  96. #endif
  97. /**
  98. This is similar to wxCHECK_GCC_VERSION but for Sun CC compiler.
  99. */
  100. #ifdef __SUNCC__
  101. /*
  102. __SUNCC__ is 0xVRP where V is major version, R release and P patch level
  103. */
  104. #define wxCHECK_SUNCC_VERSION(maj, min) (__SUNCC__ >= (((maj)<<8) | ((min)<<4)))
  105. #else
  106. #define wxCHECK_SUNCC_VERSION(maj, min) (0)
  107. #endif
  108. #ifndef __WATCOMC__
  109. # define wxWATCOM_VERSION(major,minor) 0
  110. # define wxCHECK_WATCOM_VERSION(major,minor) 0
  111. # define wxONLY_WATCOM_EARLIER_THAN(major,minor) 0
  112. # define WX_WATCOM_ONLY_CODE( x )
  113. #else
  114. # if __WATCOMC__ < 1200
  115. # error "Only Open Watcom is supported in this release"
  116. # endif
  117. # define wxWATCOM_VERSION(major,minor) ( major * 100 + minor * 10 + 1100 )
  118. # define wxCHECK_WATCOM_VERSION(major,minor) ( __WATCOMC__ >= wxWATCOM_VERSION(major,minor) )
  119. # define wxONLY_WATCOM_EARLIER_THAN(major,minor) ( __WATCOMC__ < wxWATCOM_VERSION(major,minor) )
  120. # define WX_WATCOM_ONLY_CODE( x ) x
  121. #endif
  122. /*
  123. wxCHECK_MINGW32_VERSION() is defined in wx/msw/gccpriv.h which is included
  124. later, see comments there.
  125. */
  126. #endif // _WX_COMPILER_H_