]>
git.saurik.com Git - wxWidgets.git/blob - include/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
10 /* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
12 #ifndef _WX_COMPILER_H_
13 #define _WX_COMPILER_H_
16 Compiler detection and related helpers.
20 Notice that Intel compiler can be used as Microsoft Visual C++ add-on and
21 so we should define both __INTELC__ and __VISUALC__ for it.
23 #ifdef __INTEL_COMPILER
29 define another standard symbol for Microsoft Visual C++: the standard
30 one (_MSC_VER) is also defined by some other compilers.
32 # define __VISUALC__ _MSC_VER
35 define special symbols for different VC version instead of writing tests
36 for magic numbers such as 1200, 1300 &c repeatedly
38 #if __VISUALC__ < 1100
39 # error "This Visual C++ version is too old and not supported any longer."
40 #elif __VISUALC__ < 1200
42 #elif __VISUALC__ < 1300
44 #elif __VISUALC__ < 1400
46 #elif __VISUALC__ < 1500
48 #elif __VISUALC__ < 1600
50 #elif __VISUALC__ < 1700
51 # define __VISUALC10__
52 #elif __VISUALC__ < 1800
53 # define __VISUALC11__
54 #elif __VISUALC__ < 1900
55 # define __VISUALC12__
57 # pragma message("Please update wx/compiler.h to recognize this VC++ version")
60 #elif defined(__BCPLUSPLUS__) && !defined(__BORLANDC__)
62 #elif defined(__WATCOMC__)
64 # define __SYMANTECC__
65 #elif defined(__SUNPRO_CC)
67 # define __SUNCC__ __SUNPRO_CC
71 # define __DIGITALMARS__
78 Macros for checking compiler version.
82 This macro can be used to test the gcc version and can be used like this:
84 # if wxCHECK_GCC_VERSION(3, 1)
85 ... we have gcc 3.1 or later ...
87 ... no gcc at all or gcc < 3.1 ...
90 #if defined(__GNUC__) && defined(__GNUC_MINOR__)
91 #define wxCHECK_GCC_VERSION( major, minor ) \
92 ( ( __GNUC__ > (major) ) \
93 || ( __GNUC__ == (major) && __GNUC_MINOR__ >= (minor) ) )
95 #define wxCHECK_GCC_VERSION( major, minor ) 0
99 This macro can be used to test the Visual C++ version.
102 # define wxVISUALC_VERSION(major) 0
103 # define wxCHECK_VISUALC_VERSION(major) 0
105 # define wxVISUALC_VERSION(major) ( (6 + major) * 100 )
106 # define wxCHECK_VISUALC_VERSION(major) ( __VISUALC__ >= wxVISUALC_VERSION(major) )
110 This is similar to wxCHECK_GCC_VERSION but for Sun CC compiler.
114 __SUNCC__ is 0xVRP where V is major version, R release and P patch level
116 #define wxCHECK_SUNCC_VERSION(maj, min) (__SUNCC__ >= (((maj)<<8) | ((min)<<4)))
118 #define wxCHECK_SUNCC_VERSION(maj, min) (0)
122 # define wxWATCOM_VERSION(major,minor) 0
123 # define wxCHECK_WATCOM_VERSION(major,minor) 0
124 # define wxONLY_WATCOM_EARLIER_THAN(major,minor) 0
125 # define WX_WATCOM_ONLY_CODE( x )
127 # if __WATCOMC__ < 1200
128 # error "Only Open Watcom is supported in this release"
131 # define wxWATCOM_VERSION(major,minor) ( major * 100 + minor * 10 + 1100 )
132 # define wxCHECK_WATCOM_VERSION(major,minor) ( __WATCOMC__ >= wxWATCOM_VERSION(major,minor) )
133 # define wxONLY_WATCOM_EARLIER_THAN(major,minor) ( __WATCOMC__ < wxWATCOM_VERSION(major,minor) )
134 # define WX_WATCOM_ONLY_CODE( x ) x
138 This macro can be used to check that the version of mingw32 compiler is
142 /* Check for Mingw runtime version: */
143 #if defined(__MINGW32_MAJOR_VERSION) && defined(__MINGW32_MINOR_VERSION)
144 #define wxCHECK_MINGW32_VERSION( major, minor ) \
145 ( ( ( __MINGW32_MAJOR_VERSION > (major) ) \
146 || ( __MINGW32_MAJOR_VERSION == (major) && __MINGW32_MINOR_VERSION >= (minor) ) ) )
149 MinGW-w64 project provides compilers for both Win32 and Win64 but only
150 defines the same __MINGW32__ symbol for the former as MinGW32 toolchain
151 which is quite different (notably doesn't provide many SDK headers that
152 MinGW-w64 does include). So we define a separate symbol which, unlike the
153 predefined __MINGW64__, can be used to detect this toolchain in both 32 and
156 And define __MINGW32_TOOLCHAIN__ for consistency and also because it's
157 convenient as we often want to have some workarounds only for the (old)
158 MinGW32 but not (newer) MinGW-w64, which still predefines __MINGW32__.
160 # ifdef __MINGW64_VERSION_MAJOR
161 # ifndef __MINGW64_TOOLCHAIN__
162 # define __MINGW64_TOOLCHAIN__
165 # ifndef __MINGW32_TOOLCHAIN__
166 # define __MINGW32_TOOLCHAIN__
170 #define wxCHECK_MINGW32_VERSION( major, minor ) (0)
173 #endif // _WX_COMPILER_H_