]>
Commit | Line | Data |
---|---|---|
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 | ||
10 | /* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */ | |
11 | ||
12 | #ifndef _WX_COMPILER_H_ | |
13 | #define _WX_COMPILER_H_ | |
14 | ||
15 | /* | |
16 | Compiler detection and related helpers. | |
17 | */ | |
18 | ||
19 | /* | |
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. | |
22 | */ | |
23 | #ifdef __INTEL_COMPILER | |
24 | # define __INTELC__ | |
25 | #endif | |
26 | ||
27 | #if defined(_MSC_VER) | |
28 | /* | |
29 | define another standard symbol for Microsoft Visual C++: the standard | |
30 | one (_MSC_VER) is also defined by some other compilers. | |
31 | */ | |
32 | # define __VISUALC__ _MSC_VER | |
33 | ||
34 | /* | |
35 | define special symbols for different VC version instead of writing tests | |
36 | for magic numbers such as 1200, 1300 &c repeatedly | |
37 | */ | |
38 | #if __VISUALC__ < 1100 | |
39 | # error "This Visual C++ version is too old and not supported any longer." | |
40 | #elif __VISUALC__ < 1200 | |
41 | # define __VISUALC5__ | |
42 | #elif __VISUALC__ < 1300 | |
43 | # define __VISUALC6__ | |
44 | #elif __VISUALC__ < 1400 | |
45 | # define __VISUALC7__ | |
46 | #elif __VISUALC__ < 1500 | |
47 | # define __VISUALC8__ | |
48 | #elif __VISUALC__ < 1600 | |
49 | # define __VISUALC9__ | |
50 | #elif __VISUALC__ < 1700 | |
51 | # define __VISUALC10__ | |
52 | #elif __VISUALC__ < 1800 | |
53 | # define __VISUALC11__ | |
54 | #elif __VISUALC__ < 1900 | |
55 | # define __VISUALC12__ | |
56 | #else | |
57 | # pragma message("Please update wx/compiler.h to recognize this VC++ version") | |
58 | #endif | |
59 | ||
60 | #elif defined(__BCPLUSPLUS__) && !defined(__BORLANDC__) | |
61 | # define __BORLANDC__ | |
62 | #elif defined(__WATCOMC__) | |
63 | #elif defined(__SC__) | |
64 | # define __SYMANTECC__ | |
65 | #elif defined(__SUNPRO_CC) | |
66 | # ifndef __SUNCC__ | |
67 | # define __SUNCC__ __SUNPRO_CC | |
68 | # endif /* Sun CC */ | |
69 | #elif defined(__SC__) | |
70 | # ifdef __DMC__ | |
71 | # define __DIGITALMARS__ | |
72 | # else | |
73 | # define __SYMANTEC__ | |
74 | # endif | |
75 | #endif /* compiler */ | |
76 | ||
77 | /* | |
78 | Macros for checking compiler version. | |
79 | */ | |
80 | ||
81 | /* | |
82 | This macro can be used to test the gcc version and can be used like this: | |
83 | ||
84 | # if wxCHECK_GCC_VERSION(3, 1) | |
85 | ... we have gcc 3.1 or later ... | |
86 | # else | |
87 | ... no gcc at all or gcc < 3.1 ... | |
88 | # endif | |
89 | */ | |
90 | #if defined(__GNUC__) && defined(__GNUC_MINOR__) | |
91 | #define wxCHECK_GCC_VERSION( major, minor ) \ | |
92 | ( ( __GNUC__ > (major) ) \ | |
93 | || ( __GNUC__ == (major) && __GNUC_MINOR__ >= (minor) ) ) | |
94 | #else | |
95 | #define wxCHECK_GCC_VERSION( major, minor ) 0 | |
96 | #endif | |
97 | ||
98 | /* | |
99 | This macro can be used to test the Visual C++ version. | |
100 | */ | |
101 | #ifndef __VISUALC__ | |
102 | # define wxVISUALC_VERSION(major) 0 | |
103 | # define wxCHECK_VISUALC_VERSION(major) 0 | |
104 | #else | |
105 | # define wxVISUALC_VERSION(major) ( (6 + major) * 100 ) | |
106 | # define wxCHECK_VISUALC_VERSION(major) ( __VISUALC__ >= wxVISUALC_VERSION(major) ) | |
107 | #endif | |
108 | ||
109 | /** | |
110 | This is similar to wxCHECK_GCC_VERSION but for Sun CC compiler. | |
111 | */ | |
112 | #ifdef __SUNCC__ | |
113 | /* | |
114 | __SUNCC__ is 0xVRP where V is major version, R release and P patch level | |
115 | */ | |
116 | #define wxCHECK_SUNCC_VERSION(maj, min) (__SUNCC__ >= (((maj)<<8) | ((min)<<4))) | |
117 | #else | |
118 | #define wxCHECK_SUNCC_VERSION(maj, min) (0) | |
119 | #endif | |
120 | ||
121 | #ifndef __WATCOMC__ | |
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 ) | |
126 | #else | |
127 | # if __WATCOMC__ < 1200 | |
128 | # error "Only Open Watcom is supported in this release" | |
129 | # endif | |
130 | ||
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 | |
135 | #endif | |
136 | ||
137 | /* | |
138 | This macro can be used to check that the version of mingw32 compiler is | |
139 | at least maj.min | |
140 | */ | |
141 | ||
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) ) ) ) | |
147 | #else | |
148 | #define wxCHECK_MINGW32_VERSION( major, minor ) (0) | |
149 | #endif | |
150 | ||
151 | #endif // _WX_COMPILER_H_ |