|
1 /* |
|
2 * _mingw.h |
|
3 * |
|
4 * Mingw specific macros included by ALL include files. |
|
5 * |
|
6 * This file is part of the Mingw32 package. |
|
7 * |
|
8 * Contributors: |
|
9 * Created by Mumit Khan <khan@xraylith.wisc.edu> |
|
10 * |
|
11 * THIS SOFTWARE IS NOT COPYRIGHTED |
|
12 * |
|
13 * This source code is offered for use in the public domain. You may |
|
14 * use, modify or distribute it freely. |
|
15 * |
|
16 * This code is distributed in the hope that it will be useful but |
|
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY |
|
18 * DISCLAIMED. This includes but is not limited to warranties of |
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
20 * |
|
21 */ |
|
22 |
|
23 #ifndef __MINGW_H |
|
24 #define __MINGW_H |
|
25 |
|
26 #if __GNUC__ >= 3 |
|
27 #pragma GCC system_header |
|
28 #endif |
|
29 |
|
30 /* These are defined by the user (or the compiler) |
|
31 to specify how identifiers are imported from a DLL. |
|
32 |
|
33 __DECLSPEC_SUPPORTED Defined if dllimport attribute is supported. |
|
34 __MINGW_IMPORT The attribute definition to specify imported |
|
35 variables/functions. |
|
36 _CRTIMP As above. For MS compatibility. |
|
37 __MINGW32_VERSION Runtime version. |
|
38 __MINGW32_MAJOR_VERSION Runtime major version. |
|
39 __MINGW32_MINOR_VERSION Runtime minor version. |
|
40 __MINGW32_BUILD_DATE Runtime build date. |
|
41 |
|
42 Other macros: |
|
43 |
|
44 __int64 define to be long long. Using a typedef doesn't |
|
45 work for "unsigned __int64" |
|
46 |
|
47 All headers should include this first, and then use __DECLSPEC_SUPPORTED |
|
48 to choose between the old ``__imp__name'' style or __MINGW_IMPORT |
|
49 style declarations. */ |
|
50 |
|
51 /* Try to avoid problems with outdated checks for GCC __attribute__ support. */ |
|
52 #undef __attribute__ |
|
53 |
|
54 #ifndef __GNUC__ |
|
55 # ifndef __MINGW_IMPORT |
|
56 # define __MINGW_IMPORT __declspec(dllimport) |
|
57 # endif |
|
58 # ifndef _CRTIMP |
|
59 # define _CRTIMP __declspec(dllimport) |
|
60 # endif |
|
61 # define __DECLSPEC_SUPPORTED |
|
62 # define __attribute__(x) /* nothing */ |
|
63 #else /* __GNUC__ */ |
|
64 # ifdef __declspec |
|
65 # ifndef __MINGW_IMPORT |
|
66 /* Note the extern. This is needed to work around GCC's |
|
67 limitations in handling dllimport attribute. */ |
|
68 # define __MINGW_IMPORT extern __attribute__ ((__dllimport__)) |
|
69 # endif |
|
70 # ifndef _CRTIMP |
|
71 # ifdef __USE_CRTIMP |
|
72 # define _CRTIMP __attribute__ ((dllimport)) |
|
73 # else |
|
74 # define _CRTIMP |
|
75 # endif |
|
76 # endif |
|
77 # define __DECLSPEC_SUPPORTED |
|
78 # else /* __declspec */ |
|
79 # undef __DECLSPEC_SUPPORTED |
|
80 # undef __MINGW_IMPORT |
|
81 # ifndef _CRTIMP |
|
82 # define _CRTIMP |
|
83 # endif |
|
84 # endif /* __declspec */ |
|
85 |
|
86 /* |
|
87 The next two defines can cause problems if user code adds the __cdecl attribute |
|
88 like so: |
|
89 void __attribute__ ((__cdecl)) foo(void); |
|
90 */ |
|
91 # ifndef __cdecl |
|
92 # define __cdecl __attribute__ ((__cdecl__)) |
|
93 # endif |
|
94 # ifndef __stdcall |
|
95 # define __stdcall __attribute__ ((__stdcall__)) |
|
96 # endif |
|
97 # ifndef __int64 |
|
98 # define __int64 long long |
|
99 # endif |
|
100 # ifndef __int32 |
|
101 # define __int32 long |
|
102 # endif |
|
103 # ifndef __int16 |
|
104 # define __int16 short |
|
105 # endif |
|
106 # ifndef __int8 |
|
107 # define __int8 char |
|
108 # endif |
|
109 # ifndef __small |
|
110 # define __small char |
|
111 # endif |
|
112 # ifndef __hyper |
|
113 # define __hyper long long |
|
114 # endif |
|
115 #endif /* __GNUC__ */ |
|
116 |
|
117 #if defined (__GNUC__) && defined (__GNUC_MINOR__) |
|
118 #define __MINGW_GNUC_PREREQ(major, minor) \ |
|
119 (__GNUC__ > (major) \ |
|
120 || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) |
|
121 #else |
|
122 #define __MINGW_GNUC_PREREQ(major, minor) 0 |
|
123 #endif |
|
124 |
|
125 #ifdef __cplusplus |
|
126 # define __CRT_INLINE inline |
|
127 #else |
|
128 # if __GNUC_STDC_INLINE__ |
|
129 # define __CRT_INLINE extern inline __attribute__((__gnu_inline__)) |
|
130 # else |
|
131 # define __CRT_INLINE extern __inline__ |
|
132 # endif |
|
133 #endif |
|
134 |
|
135 #ifdef __cplusplus |
|
136 # define __UNUSED_PARAM(x) |
|
137 #else |
|
138 # ifdef __GNUC__ |
|
139 # define __UNUSED_PARAM(x) x __attribute__ ((__unused__)) |
|
140 # else |
|
141 # define __UNUSED_PARAM(x) x |
|
142 # endif |
|
143 #endif |
|
144 |
|
145 #ifdef __GNUC__ |
|
146 #define __MINGW_ATTRIB_NORETURN __attribute__ ((__noreturn__)) |
|
147 #define __MINGW_ATTRIB_CONST __attribute__ ((__const__)) |
|
148 #else |
|
149 #define __MINGW_ATTRIB_NORETURN |
|
150 #define __MINGW_ATTRIB_CONST |
|
151 #endif |
|
152 |
|
153 #if __MINGW_GNUC_PREREQ (3, 0) |
|
154 #define __MINGW_ATTRIB_MALLOC __attribute__ ((__malloc__)) |
|
155 #define __MINGW_ATTRIB_PURE __attribute__ ((__pure__)) |
|
156 #else |
|
157 #define __MINGW_ATTRIB_MALLOC |
|
158 #define __MINGW_ATTRIB_PURE |
|
159 #endif |
|
160 |
|
161 /* Attribute `nonnull' was valid as of gcc 3.3. We don't use GCC's |
|
162 variadiac macro facility, because variadic macros cause syntax |
|
163 errors with --traditional-cpp. */ |
|
164 #if __MINGW_GNUC_PREREQ (3, 3) |
|
165 #define __MINGW_ATTRIB_NONNULL(arg) __attribute__ ((__nonnull__ (arg))) |
|
166 #else |
|
167 #define __MINGW_ATTRIB_NONNULL(arg) |
|
168 #endif /* GNUC >= 3.3 */ |
|
169 |
|
170 #if __MINGW_GNUC_PREREQ (3, 1) |
|
171 #define __MINGW_ATTRIB_DEPRECATED __attribute__ ((__deprecated__)) |
|
172 #else |
|
173 #define __MINGW_ATTRIB_DEPRECATED |
|
174 #endif /* GNUC >= 3.1 */ |
|
175 |
|
176 #if __MINGW_GNUC_PREREQ (3, 3) |
|
177 #define __MINGW_NOTHROW __attribute__ ((__nothrow__)) |
|
178 #else |
|
179 #define __MINGW_NOTHROW |
|
180 #endif /* GNUC >= 3.3 */ |
|
181 |
|
182 |
|
183 /* TODO: Mark (almost) all CRT functions as __MINGW_NOTHROW. This will |
|
184 allow GCC to optimize away some EH unwind code, at least in DW2 case. */ |
|
185 |
|
186 #ifndef __MSVCRT_VERSION__ |
|
187 /* High byte is the major version, low byte is the minor. */ |
|
188 # define __MSVCRT_VERSION__ 0x0600 |
|
189 #endif |
|
190 |
|
191 #define __MINGW32_VERSION 3.14 |
|
192 #define __MINGW32_MAJOR_VERSION 3 |
|
193 #define __MINGW32_MINOR_VERSION 14 |
|
194 |
|
195 #endif /* __MINGW_H */ |