4 * Mingw specific macros included by ALL include files.
6 * This file is part of the Mingw32 package.
9 * Created by Mumit Khan <khan@xraylith.wisc.edu>
11 * THIS SOFTWARE IS NOT COPYRIGHTED
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
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.
27 #pragma GCC system_header
30 /* These are defined by the user (or the compiler)
31 to specify how identifiers are imported from a DLL.
33 __DECLSPEC_SUPPORTED Defined if dllimport attribute is supported.
34 __MINGW_IMPORT The attribute definition to specify imported
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.
44 __int64 define to be long long. Using a typedef doesn't
45 work for "unsigned __int64"
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. */
51 /* Try to avoid problems with outdated checks for GCC __attribute__ support. */
56 # ifndef __MINGW_IMPORT
57 # define __MINGW_IMPORT __declspec(dllimport)
60 # define _CRTIMP __declspec(dllimport)
63 # ifndef __MINGW_IMPORT
64 # define __MINGW_IMPORT
70 # define __DECLSPEC_SUPPORTED
71 # define __attribute__(x) /* nothing */
72 # define __restrict__ /* nothing */
73 #elif defined(__GNUC__)
75 # ifndef __MINGW_IMPORT
77 /* Note the extern. This is needed to work around GCC's
78 limitations in handling dllimport attribute. */
79 # define __MINGW_IMPORT extern __attribute__ ((__dllimport__))
81 # define __MINGW_IMPORT extern
87 # define _CRTIMP __attribute__ ((dllimport))
95 # define __DECLSPEC_SUPPORTED
96 # else /* __declspec */
97 # undef __DECLSPEC_SUPPORTED
98 # undef __MINGW_IMPORT
102 # endif /* __declspec */
105 The next two defines can cause problems if user code adds the __cdecl attribute
107 void __attribute__ ((__cdecl)) foo(void);
110 # define __cdecl __attribute__ ((__cdecl__))
113 # define __stdcall __attribute__ ((__stdcall__))
116 # define __int64 long long
119 # define __int32 long
122 # define __int16 short
128 # define __small char
131 # define __hyper long long
134 # ifndef __MINGW_IMPORT
135 # define __MINGW_IMPORT __declspec(dllimport)
138 # define _CRTIMP __declspec(dllimport)
140 # define __DECLSPEC_SUPPORTED
141 # define __attribute__(x) /* nothing */
142 #endif /* __GNUC__ */
144 #if defined (__GNUC__) && defined (__GNUC_MINOR__)
145 #define __MINGW_GNUC_PREREQ(major, minor) \
146 (__GNUC__ > (major) \
147 || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
149 #define __MINGW_GNUC_PREREQ(major, minor) 0
152 #if defined (_MSC_VER)
153 #define __MINGW_MSC_PREREQ(major, minor) \
154 ((_MSC_VER / 100) > (major) \
155 || ((_MSC_VER / 100) == (major) && (_MSC_VER % 100) >= (minor)))
157 #define __MINGW_MSC_PREREQ(major, minor) 0
161 # define __CRT_INLINE inline
163 # if defined(_MSC_VER)
164 # define __CRT_INLINE __inline
165 # elif __GNUC_STDC_INLINE__
166 # define __CRT_INLINE extern inline __attribute__((__gnu_inline__))
168 # define __CRT_INLINE extern __inline__
173 # define __UNUSED_PARAM(x)
176 # define __UNUSED_PARAM(x) x __attribute__ ((__unused__))
178 # define __UNUSED_PARAM(x) x
183 #define __MINGW_ATTRIB_NORETURN __attribute__ ((__noreturn__))
184 #define __MINGW_ATTRIB_CONST __attribute__ ((__const__))
185 #elif __MINGW_MSC_PREREQ(12, 0)
186 #define __MINGW_ATTRIB_NORETURN __declspec(noreturn)
187 #define __MINGW_ATTRIB_CONST
189 #define __MINGW_ATTRIB_NORETURN
190 #define __MINGW_ATTRIB_CONST
193 #if defined(__GNUC__)
194 #define __mingw_va_start(v,l) __builtin_va_start(v,l)
195 #define __mingw_va_end(v) __builtin_va_end(v)
196 #define __mingw_va_arg(v,l) __builtin_va_arg(v,l)
197 #define __mingw_va_copy(d,s) __builtin_va_copy(d,s)
198 #elif defined(_MSC_VER)
199 #define __mingw_va_start(v,l) __msc_va_start(v,l)
200 #define __mingw_va_end(v) __msc_va_end(v)
201 #define __mingw_va_arg(v,l) __msc_va_arg(v,l)
202 #define __mingw_va_copy(d,s) __msc_va_copy(d,s)
205 #if __MINGW_GNUC_PREREQ (3, 0)
206 #define __MINGW_ATTRIB_MALLOC __attribute__ ((__malloc__))
207 #define __MINGW_ATTRIB_PURE __attribute__ ((__pure__))
208 #elif __MINGW_MSC_PREREQ (14, 0)
209 #define __MINGW_ATTRIB_MALLOC __declspec(noalias) __declspec(restrict)
210 #define __MINGW_ATTRIB_PURE
212 #define __MINGW_ATTRIB_MALLOC
213 #define __MINGW_ATTRIB_PURE
216 /* Attribute `nonnull' was valid as of gcc 3.3. We don't use GCC's
217 variadiac macro facility, because variadic macros cause syntax
218 errors with --traditional-cpp. */
219 #if __MINGW_GNUC_PREREQ (3, 3)
220 #define __MINGW_ATTRIB_NONNULL(arg) __attribute__ ((__nonnull__ (arg)))
222 #define __MINGW_ATTRIB_NONNULL(arg)
223 #endif /* GNUC >= 3.3 */
225 #if __MINGW_GNUC_PREREQ (3, 1)
226 #define __MINGW_ATTRIB_DEPRECATED __attribute__ ((__deprecated__))
227 #elif __MINGW_MSC_PREREQ (12, 0)
228 #define __MINGW_ATTRIB_DEPRECATED __declspec (deprecated)
230 #define __MINGW_ATTRIB_DEPRECATED
233 #if __MINGW_GNUC_PREREQ (3, 3)
234 #define __MINGW_NOTHROW __attribute__ ((__nothrow__))
235 #elif __MINGW_MSC_PREREQ (12, 0) && defined (__cplusplus)
236 #define __MINGW_NOTHROW __declspec (nothrow)
238 #define __MINGW_NOTHROW
241 /* TODO: Mark (almost) all CRT functions as __MINGW_NOTHROW. This will
242 allow GCC to optimize away some EH unwind code, at least in DW2 case. */
244 #ifndef __MSVCRT_VERSION__
245 /* High byte is the major version, low byte is the minor. */
246 # define __MSVCRT_VERSION__ 0x0600
249 #define __MINGW32_VERSION 3.13
250 #define __MINGW32_MAJOR_VERSION 3
251 #define __MINGW32_MINOR_VERSION 13
253 #endif /* __MINGW_H */