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 #elif __VISUALC__ < 2000
57     /* There is no __VISUALC13__! */
58 #   define __VISUALC14__
59 #else
60     /*
61         Don't forget to update include/msvc/wx/setup.h as well when adding
62         support for a newer MSVC version here.
63      */
64 #   pragma message("Please update wx/compiler.h to recognize this VC++ version")
65 #endif
66 
67 #elif defined(__BCPLUSPLUS__) && !defined(__BORLANDC__)
68 #   define __BORLANDC__
69 #elif defined(__WATCOMC__)
70 #elif defined(__SC__)
71 #   define __SYMANTECC__
72 #elif defined(__SUNPRO_CC)
73 #   ifndef __SUNCC__
74 #       define __SUNCC__ __SUNPRO_CC
75 #   endif /* Sun CC */
76 #elif defined(__SC__)
77 #    ifdef __DMC__
78 #         define __DIGITALMARS__
79 #    else
80 #         define __SYMANTEC__
81 #    endif
82 #endif  /* compiler */
83 
84 /*
85    Macros for checking compiler version.
86 */
87 
88 /*
89    This macro can be used to test the gcc version and can be used like this:
90 
91 #    if wxCHECK_GCC_VERSION(3, 1)
92         ... we have gcc 3.1 or later ...
93 #    else
94         ... no gcc at all or gcc < 3.1 ...
95 #    endif
96 */
97 #if defined(__GNUC__) && defined(__GNUC_MINOR__)
98     #define wxCHECK_GCC_VERSION( major, minor ) \
99         ( ( __GNUC__ > (major) ) \
100             || ( __GNUC__ == (major) && __GNUC_MINOR__ >= (minor) ) )
101 #else
102     #define wxCHECK_GCC_VERSION( major, minor ) 0
103 #endif
104 
105 /*
106    This macro can be used to test the Visual C++ version.
107 */
108 #ifndef __VISUALC__
109 #   define wxVISUALC_VERSION(major) 0
110 #   define wxCHECK_VISUALC_VERSION(major) 0
111 #else
112     /*
113         Things used to be simple with the _MSC_VER value and the version number
114         increasing in lock step, but _MSC_VER value of 1900 is VC14 and not the
115         non existing (presumably for the superstitious reasons) VC13, so we now
116         need to account for this with an extra offset.
117      */
118 #   define wxVISUALC_VERSION(major) ( (6 + (major >= 14 ? 1 : 0) + major) * 100 )
119 #   define wxCHECK_VISUALC_VERSION(major) ( __VISUALC__ >= wxVISUALC_VERSION(major) )
120 #endif
121 
122 /**
123     This is similar to wxCHECK_GCC_VERSION but for Sun CC compiler.
124  */
125 #ifdef __SUNCC__
126     /*
127        __SUNCC__ is 0xVRP where V is major version, R release and P patch level
128      */
129     #define wxCHECK_SUNCC_VERSION(maj, min) (__SUNCC__ >= (((maj)<<8) | ((min)<<4)))
130 #else
131     #define wxCHECK_SUNCC_VERSION(maj, min) (0)
132 #endif
133 
134 #ifndef __WATCOMC__
135 #   define wxWATCOM_VERSION(major,minor) 0
136 #   define wxCHECK_WATCOM_VERSION(major,minor) 0
137 #   define wxONLY_WATCOM_EARLIER_THAN(major,minor) 0
138 #   define WX_WATCOM_ONLY_CODE( x )
139 #else
140 #   if __WATCOMC__ < 1200
141 #       error "Only Open Watcom is supported in this release"
142 #   endif
143 
144 #   define wxWATCOM_VERSION(major,minor) ( major * 100 + minor * 10 + 1100 )
145 #   define wxCHECK_WATCOM_VERSION(major,minor) ( __WATCOMC__ >= wxWATCOM_VERSION(major,minor) )
146 #   define wxONLY_WATCOM_EARLIER_THAN(major,minor) ( __WATCOMC__ < wxWATCOM_VERSION(major,minor) )
147 #   define WX_WATCOM_ONLY_CODE( x )  x
148 #endif
149 
150 /*
151     wxCHECK_MINGW32_VERSION() is defined in wx/msw/gccpriv.h which is included
152     later, see comments there.
153  */
154 
155 #endif // _WX_COMPILER_H_
156