5 * Mingw specific macros included by ALL include files.
7 * This file is part of the Mingw32 package.
10 * Created by Mumit Khan <khan@xraylith.wisc.edu>
12 * THIS SOFTWARE IS NOT COPYRIGHTED
14 * This source code is offered for use in the public domain. You may
15 * use, modify or distribute it freely.
17 * This code is distributed in the hope that it will be useful but
18 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
19 * DISCLAIMED. This includes but is not limited to warranties of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
25 #define __MINGW32_VERSION 3.20
26 #define __MINGW32_MAJOR_VERSION 3
27 #define __MINGW32_MINOR_VERSION 20
28 #define __MINGW32_PATCHLEVEL 0
32 #pragma GCC system_header
36 /* These are defined by the user (or the compiler)
37 to specify how identifiers are imported from a DLL.
39 __DECLSPEC_SUPPORTED Defined if dllimport attribute is supported.
40 __MINGW_IMPORT The attribute definition to specify imported
42 _CRTIMP As above. For MS compatibility.
43 __MINGW32_VERSION Runtime version.
44 __MINGW32_MAJOR_VERSION Runtime major version.
45 __MINGW32_MINOR_VERSION Runtime minor version.
46 __MINGW32_BUILD_DATE Runtime build date.
48 Macros to enable MinGW features which deviate from standard MSVC
49 compatible behaviour; these may be specified directly in user code,
50 activated implicitly, (e.g. by specifying _POSIX_C_SOURCE or such),
51 or by inclusion in __MINGW_FEATURES__:
53 __USE_MINGW_ANSI_STDIO Select a more ANSI C99 compatible
54 implementation of printf() and friends.
58 __int64 define to be long long. Using a typedef
59 doesn't work for "unsigned __int64"
61 All headers should include this first, and then use __DECLSPEC_SUPPORTED
62 to choose between the old ``__imp__name'' style or __MINGW_IMPORT
63 style declarations. */
66 /* Manifest definitions identifying the flag bits, controlling activation
67 * of MinGW features, as specified by the user in __MINGW_FEATURES__.
69 #define __MINGW_ANSI_STDIO__ 0x0000000000000001ULL
71 * The following three are not yet formally supported; they are
72 * included here, to document anticipated future usage.
74 #define __MINGW_LC_EXTENSIONS__ 0x0000000000000050ULL
75 #define __MINGW_LC_MESSAGES__ 0x0000000000000010ULL
76 #define __MINGW_LC_ENVVARS__ 0x0000000000000040ULL
78 /* Try to avoid problems with outdated checks for GCC __attribute__ support. */
82 # undef __DECLSPEC_SUPPORTED
83 # ifndef __MINGW_IMPORT
84 # define __MINGW_IMPORT extern
90 # define __cdecl _Pragma("cdecl")
93 # define __stdcall _Pragma("stdcall")
96 # define __int64 long long
102 # define __int16 short
108 # define __small char
111 # define __hyper long long
113 # ifndef __volatile__
114 # define __volatile__ volatile
116 # ifndef __restrict__
117 # define __restrict__ restrict
119 # define NONAMELESSUNION
120 #elif defined(__GNUC__)
122 # ifndef __MINGW_IMPORT
123 /* Note the extern. This is needed to work around GCC's
124 limitations in handling dllimport attribute. */
125 # define __MINGW_IMPORT extern __attribute__ ((__dllimport__))
129 # define _CRTIMP __attribute__ ((dllimport))
134 # define __DECLSPEC_SUPPORTED
135 # else /* __declspec */
136 # undef __DECLSPEC_SUPPORTED
137 # undef __MINGW_IMPORT
141 # endif /* __declspec */
143 * The next two defines can cause problems if user code adds the
144 * __cdecl attribute like so:
145 * void __attribute__ ((__cdecl)) foo(void);
148 # define __cdecl __attribute__ ((__cdecl__))
151 # define __stdcall __attribute__ ((__stdcall__))
154 # define __int64 long long
157 # define __int32 long
160 # define __int16 short
166 # define __small char
169 # define __hyper long long
171 #else /* ! __GNUC__ && ! __PCC__ */
172 # ifndef __MINGW_IMPORT
173 # define __MINGW_IMPORT __declspec(dllimport)
176 # define _CRTIMP __declspec(dllimport)
178 # define __DECLSPEC_SUPPORTED
179 # define __attribute__(x) /* nothing */
182 #if defined (__GNUC__) && defined (__GNUC_MINOR__)
183 #define __MINGW_GNUC_PREREQ(major, minor) \
184 (__GNUC__ > (major) \
185 || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
187 #define __MINGW_GNUC_PREREQ(major, minor) 0
191 # define _EXTERN_C extern "C"
192 # define _BEGIN_C_DECLS extern "C" {
193 # define _END_C_DECLS }
195 # define __CRT_INLINE inline
198 # define _EXTERN_C extern
199 # define _BEGIN_C_DECLS
200 # define _END_C_DECLS
202 # if __GNUC_STDC_INLINE__
203 # define __CRT_INLINE extern inline __attribute__((__gnu_inline__))
205 # define __CRT_INLINE extern __inline__
210 /* A special form of __CRT_INLINE, to ALWAYS request inlining when
211 * possible is provided; originally specified as _CRTALIAS, this is
212 * now deprecated in favour of __CRT_ALIAS, for syntactic consistency
213 * with __CRT_INLINE itself.
215 # define _CRTALIAS __CRT_INLINE __attribute__((__always_inline__))
216 # define __CRT_ALIAS __CRT_INLINE __attribute__((__always_inline__))
218 # define _CRTALIAS __CRT_INLINE /* deprecated form */
219 # define __CRT_ALIAS __CRT_INLINE /* preferred form */
222 * Each function which is implemented as a __CRT_ALIAS should also be
223 * accompanied by an externally visible interface. The following pair
224 * of macros provide a mechanism for implementing this, either as a stub
225 * redirecting to an alternative external function, or by compilation of
226 * the normally inlined code into free standing object code; each macro
227 * provides a way for us to offer arbitrary hints for use by the build
228 * system, while remaining transparent to the compiler.
230 #define __JMPSTUB__(__BUILD_HINT__)
231 #define __LIBIMPL__(__BUILD_HINT__)
234 # define __UNUSED_PARAM(x)
237 # define __UNUSED_PARAM(x) x __attribute__ ((__unused__))
239 # define __UNUSED_PARAM(x) x
244 #define __MINGW_ATTRIB_NORETURN __attribute__ ((__noreturn__))
245 #define __MINGW_ATTRIB_CONST __attribute__ ((__const__))
247 #define __MINGW_ATTRIB_NORETURN
248 #define __MINGW_ATTRIB_CONST
251 #if __MINGW_GNUC_PREREQ (3, 0)
252 #define __MINGW_ATTRIB_MALLOC __attribute__ ((__malloc__))
253 #define __MINGW_ATTRIB_PURE __attribute__ ((__pure__))
255 #define __MINGW_ATTRIB_MALLOC
256 #define __MINGW_ATTRIB_PURE
259 /* Attribute `nonnull' was valid as of gcc 3.3. We don't use GCC's
260 variadiac macro facility, because variadic macros cause syntax
261 errors with --traditional-cpp. */
262 #if __MINGW_GNUC_PREREQ (3, 3)
263 #define __MINGW_ATTRIB_NONNULL(arg) __attribute__ ((__nonnull__ (arg)))
265 #define __MINGW_ATTRIB_NONNULL(arg)
266 #endif /* GNUC >= 3.3 */
268 #if __MINGW_GNUC_PREREQ (3, 1)
269 #define __MINGW_ATTRIB_DEPRECATED __attribute__ ((__deprecated__))
271 #define __MINGW_ATTRIB_DEPRECATED
272 #endif /* GNUC >= 3.1 */
274 #if __MINGW_GNUC_PREREQ (3, 3)
275 #define __MINGW_NOTHROW __attribute__ ((__nothrow__))
277 #define __MINGW_NOTHROW
278 #endif /* GNUC >= 3.3 */
281 /* TODO: Mark (almost) all CRT functions as __MINGW_NOTHROW. This will
282 allow GCC to optimize away some EH unwind code, at least in DW2 case. */
284 #ifndef __MSVCRT_VERSION__
285 /* High byte is the major version, low byte is the minor. */
286 # define __MSVCRT_VERSION__ 0x0600
289 /* Activation of MinGW specific extended features:
291 #ifndef __USE_MINGW_ANSI_STDIO
293 * If user didn't specify it explicitly...
295 # if defined __STRICT_ANSI__ || defined _ISOC99_SOURCE \
296 || defined _POSIX_SOURCE || defined _POSIX_C_SOURCE \
297 || defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED \
298 || defined _GNU_SOURCE || defined _BSD_SOURCE \
299 || defined _SVID_SOURCE
301 * but where any of these source code qualifiers are specified,
302 * then assume ANSI I/O standards are preferred over Microsoft's...
304 # define __USE_MINGW_ANSI_STDIO 1
307 * otherwise use whatever __MINGW_FEATURES__ specifies...
309 # define __USE_MINGW_ANSI_STDIO (__MINGW_FEATURES__ & __MINGW_ANSI_STDIO__)
313 /* Only Microsoft could attempt to justify this insanity: when building
314 * a UTF-16LE application -- apparently their understanding of Unicode is
315 * limited to this -- the C/C++ runtime requires that the user must define
316 * the _UNICODE macro, while to use the Windows API's UTF-16LE capabilities,
317 * it is the UNICODE macro, (without the leading underscore), which must be
318 * defined. The (bogus) explanation appears to be that it is the C standard
319 * which dictates the requirement for the leading underscore, to avoid any
320 * possible conflict with a user defined symbol; (bogus because the macro
321 * must be user defined anyway -- it is not a private symbol -- and in
322 * any case, the Windows API already reserves the UNICODE symbol as
323 * a user defined macro, with equivalent intent.
325 * The real explanation, of course, is that this is just another example
326 * of Microsoft irrationality; in any event, there seems to be no sane
327 * scenario in which defining one without the other would be required,
328 * or indeed would not raise potential for internal inconsistency, so we
329 * ensure that either both are, or neither is defined.
331 #if defined UNICODE && ! defined _UNICODE
332 # define _UNICODE UNICODE
334 #if defined _UNICODE && ! defined UNICODE
335 # define UNICODE _UNICODE
338 #endif /* __MINGW_H */