stash
[wine/wine64.git] / include / windef.h
blob5ceb8e6ae4e7c7050641b1e9744dd14ad57b213d
1 /*
2 * Basic types definitions
4 * Copyright 1996 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef _WINDEF_
22 #define _WINDEF_
24 #ifndef WINVER
25 #define WINVER 0x0500
26 #endif
28 #ifndef NO_STRICT
29 # ifndef STRICT
30 # define STRICT
31 # endif /* STRICT */
32 #endif /* NO_STRICT */
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
38 /* Calling conventions definitions */
40 #if defined(__x86_64__) && !defined(_WIN64)
41 #define _WIN64
42 #endif
44 #ifndef _WIN64
45 # if defined(__i386__) && !defined(_X86_)
46 # define _X86_
47 # endif
48 # if defined(_X86_) && !defined(__i386__)
49 # define __i386__
50 # endif
51 #endif
53 #ifndef __stdcall
54 # ifdef __i386__
55 # ifdef __GNUC__
56 # ifdef __APPLE__ /* Mac OS X uses a 16-byte aligned stack and not a 4-byte one */
57 # define __stdcall __attribute__((__stdcall__)) __attribute__((__force_align_arg_pointer__))
58 # else
59 # define __stdcall __attribute__((__stdcall__))
60 # endif
61 # elif defined(_MSC_VER)
62 /* Nothing needs to be done. __stdcall already exists */
63 # else
64 # error You need to define __stdcall for your compiler
65 # endif
66 # elif defined(__x86_64__) && defined (__GNUC__)
67 # define __stdcall __attribute__((ms_abi))
68 # else /* __i386__ */
69 # define __stdcall
70 # endif /* __i386__ */
71 #endif /* __stdcall */
73 #ifndef __cdecl
74 # if defined(__i386__) && defined(__GNUC__)
75 # ifdef __APPLE__ /* Mac OS X uses 16-byte aligned stack and not a 4-byte one */
76 # define __cdecl __attribute__((__cdecl__)) __attribute__((__force_align_arg_pointer__))
77 # else
78 # define __cdecl __attribute__((__cdecl__))
79 # endif
80 # elif defined(__x86_64__) && defined (__GNUC__)
81 # define __cdecl __attribute__((ms_abi))
82 # elif !defined(_MSC_VER)
83 # define __cdecl
84 # endif
85 #endif /* __cdecl */
87 #if defined(__x86_64__) && defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4))) && !defined(__MINGW64__)
88 /* redefine va_XXX to be compatible only with ms calling convention
89 * Note: This means all variadic functions in wine will have to have the ms calling convention too,
90 * including the functions in wine/debug.h
92 /* Include first to avoid conflicts */
93 #include <stdarg.h>
95 #define ms_va_list __builtin_ms_va_list
96 /* va_arg is same for ms and sysv */
97 #define ms_va_arg __builtin_va_arg
98 #define ms_va_start __builtin_ms_va_start
99 #define ms_va_copy __builtin_ms_va_copy
100 #define ms_va_end __builtin_ms_va_end
101 #elif !defined(RC_INVOKED)
102 /* Include first to avoid conflicts */
103 #include <stdarg.h>
105 #define ms_va_list va_list
106 #define ms_va_arg va_arg
107 #define ms_va_start va_start
108 #define ms_va_copy va_copy
109 #define ms_va_end va_end
110 #endif
112 #ifdef __WINESRC__
113 #define __ONLY_IN_WINELIB(x) do_not_use_this_in_wine
114 #else
115 #define __ONLY_IN_WINELIB(x) x
116 #endif
118 #ifndef pascal
119 #define pascal __ONLY_IN_WINELIB(__stdcall)
120 #endif
121 #ifndef _pascal
122 #define _pascal __ONLY_IN_WINELIB(__stdcall)
123 #endif
124 #ifndef _stdcall
125 #define _stdcall __ONLY_IN_WINELIB(__stdcall)
126 #endif
127 #ifndef _fastcall
128 #define _fastcall __ONLY_IN_WINELIB(__stdcall)
129 #endif
130 #ifndef __fastcall
131 #define __fastcall __ONLY_IN_WINELIB(__stdcall)
132 #endif
133 #ifndef __export
134 #define __export __ONLY_IN_WINELIB(__stdcall)
135 #endif
136 #ifndef cdecl
137 #define cdecl __ONLY_IN_WINELIB(__cdecl)
138 #endif
139 #ifndef _cdecl
140 #define _cdecl __ONLY_IN_WINELIB(__cdecl)
141 #endif
143 #ifndef near
144 #define near __ONLY_IN_WINELIB(/* nothing */)
145 #endif
146 #ifndef far
147 #define far __ONLY_IN_WINELIB(/* nothing */)
148 #endif
149 #ifndef _near
150 #define _near __ONLY_IN_WINELIB(/* nothing */)
151 #endif
152 #ifndef _far
153 #define _far __ONLY_IN_WINELIB(/* nothing */)
154 #endif
155 #ifndef NEAR
156 #define NEAR __ONLY_IN_WINELIB(/* nothing */)
157 #endif
158 #ifndef FAR
159 #define FAR __ONLY_IN_WINELIB(/* nothing */)
160 #endif
162 #ifndef _MSC_VER
163 # ifndef _declspec
164 # define _declspec(x) __ONLY_IN_WINELIB(/* nothing */)
165 # endif
166 # ifndef __declspec
167 # define __declspec(x) __ONLY_IN_WINELIB(/* nothing */)
168 # endif
169 #endif
171 #ifdef _MSC_VER
172 # define inline __inline
173 #endif
175 #define CALLBACK __stdcall
176 #define WINAPI __stdcall
177 #define APIPRIVATE __stdcall
178 #define PASCAL __stdcall
179 #define CDECL __cdecl
180 #define _CDECL __cdecl
181 #define WINAPIV __cdecl
182 #define APIENTRY WINAPI
183 #define CONST const
185 /* Misc. constants. */
187 #undef NULL
188 #ifdef __cplusplus
189 #define NULL 0
190 #else
191 #define NULL ((void*)0)
192 #endif
194 #ifdef FALSE
195 #undef FALSE
196 #endif
197 #define FALSE 0
199 #ifdef TRUE
200 #undef TRUE
201 #endif
202 #define TRUE 1
204 #ifndef IN
205 #define IN
206 #endif
208 #ifndef OUT
209 #define OUT
210 #endif
212 #ifndef OPTIONAL
213 #define OPTIONAL
214 #endif
216 /* Standard data types */
218 typedef void *LPVOID;
219 typedef const void *LPCVOID;
220 typedef int BOOL, *PBOOL, *LPBOOL;
221 typedef unsigned char BYTE, *PBYTE, *LPBYTE;
222 typedef unsigned char UCHAR, *PUCHAR;
223 typedef unsigned short WORD, *PWORD, *LPWORD;
224 typedef unsigned short USHORT, *PUSHORT;
225 typedef int INT, *PINT, *LPINT;
226 typedef unsigned int UINT, *PUINT;
227 typedef float FLOAT, *PFLOAT;
228 typedef char *PSZ;
229 #ifdef _MSC_VER
230 typedef long *LPLONG;
231 typedef unsigned long DWORD, *PDWORD, *LPDWORD;
232 typedef unsigned long ULONG, *PULONG;
233 #else
234 typedef int *LPLONG;
235 typedef unsigned int DWORD, *PDWORD, *LPDWORD;
236 typedef unsigned int ULONG, *PULONG;
237 #endif
239 /* Macros to map Winelib names to the correct implementation name */
240 /* Note that Winelib is purely Win32. */
242 #ifdef __WINESRC__
243 #define WINE_NO_UNICODE_MACROS
244 #endif
246 #ifdef WINE_NO_UNICODE_MACROS
247 # define WINELIB_NAME_AW(func) \
248 func##_must_be_suffixed_with_W_or_A_in_this_context \
249 func##_must_be_suffixed_with_W_or_A_in_this_context
250 #else /* WINE_NO_UNICODE_MACROS */
251 # ifdef UNICODE
252 # define WINELIB_NAME_AW(func) func##W
253 # else
254 # define WINELIB_NAME_AW(func) func##A
255 # endif
256 #endif /* WINE_NO_UNICODE_MACROS */
258 #ifdef WINE_NO_UNICODE_MACROS
259 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
260 #else
261 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
262 #endif
264 #include <winnt.h>
266 /* Polymorphic types */
268 typedef UINT_PTR WPARAM;
269 typedef LONG_PTR LPARAM;
270 typedef LONG_PTR LRESULT;
272 /* Integer types */
274 typedef WORD ATOM;
275 typedef DWORD COLORREF, *LPCOLORREF;
278 /* Handle types */
280 typedef int HFILE;
281 DECLARE_HANDLE(HACCEL);
282 DECLARE_HANDLE(HBITMAP);
283 DECLARE_HANDLE(HBRUSH);
284 DECLARE_HANDLE(HCOLORSPACE);
285 DECLARE_HANDLE(HDC);
286 DECLARE_HANDLE(HDESK);
287 DECLARE_HANDLE(HENHMETAFILE);
288 DECLARE_HANDLE(HFONT);
289 DECLARE_HANDLE(HGLRC);
290 DECLARE_HANDLE(HHOOK);
291 DECLARE_HANDLE(HICON);
292 DECLARE_HANDLE(HINSTANCE);
293 DECLARE_HANDLE(HKEY);
294 typedef HKEY *PHKEY;
295 DECLARE_HANDLE(HKL);
296 DECLARE_HANDLE(HMENU);
297 DECLARE_HANDLE(HMETAFILE);
298 DECLARE_HANDLE(HMONITOR);
299 DECLARE_HANDLE(HPALETTE);
300 DECLARE_HANDLE(HPEN);
301 DECLARE_HANDLE(HRGN);
302 DECLARE_HANDLE(HRSRC);
303 DECLARE_HANDLE(HTASK);
304 DECLARE_HANDLE(HWINEVENTHOOK);
305 DECLARE_HANDLE(HWINSTA);
306 DECLARE_HANDLE(HWND);
308 /* Handle types that must remain interchangeable even with strict on */
310 typedef HINSTANCE HMODULE;
311 typedef HANDLE HGDIOBJ;
312 typedef HANDLE HGLOBAL;
313 typedef HANDLE HLOCAL;
314 typedef HANDLE GLOBALHANDLE;
315 typedef HANDLE LOCALHANDLE;
316 typedef HICON HCURSOR;
318 /* Callback function pointers types */
320 typedef INT_PTR (CALLBACK *FARPROC)();
321 typedef INT_PTR (CALLBACK *NEARPROC)();
322 typedef INT_PTR (CALLBACK *PROC)();
325 /* Macros to split words and longs. */
327 #define LOBYTE(w) ((BYTE)((DWORD_PTR)(w) & 0xFF))
328 #define HIBYTE(w) ((BYTE)((DWORD_PTR)(w) >> 8))
330 #define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xFFFF))
331 #define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16))
333 #define MAKEWORD(low,high) ((WORD)(((BYTE)((DWORD_PTR)(low) & 0xFF)) | ((WORD)((BYTE)((DWORD_PTR)(high) & 0xFF))) << 8))
334 #define MAKELONG(low,high) ((LONG)(((WORD)((DWORD_PTR)(low) & 0xFFFF)) | ((DWORD)((WORD)((DWORD_PTR)(high) & 0xFFFF))) << 16))
336 /* min and max macros */
337 #ifndef NOMINMAX
338 #ifndef max
339 #define max(a,b) (((a) > (b)) ? (a) : (b))
340 #endif
341 #ifndef min
342 #define min(a,b) (((a) < (b)) ? (a) : (b))
343 #endif
344 #endif /* NOMINMAX */
346 #ifdef MAX_PATH /* Work-around for Mingw */
347 #undef MAX_PATH
348 #endif /* MAX_PATH */
350 #define MAX_PATH 260
351 #define HFILE_ERROR ((HFILE)-1)
353 /* The SIZE structure */
354 typedef struct tagSIZE
356 LONG cx;
357 LONG cy;
358 } SIZE, *PSIZE, *LPSIZE;
360 typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;
362 /* The POINT structure */
363 typedef struct tagPOINT
365 LONG x;
366 LONG y;
367 } POINT, *PPOINT, *LPPOINT;
369 typedef struct _POINTL
371 LONG x;
372 LONG y;
373 } POINTL, *PPOINTL;
375 /* The POINTS structure */
377 typedef struct tagPOINTS
379 #ifdef WORDS_BIGENDIAN
380 SHORT y;
381 SHORT x;
382 #else
383 SHORT x;
384 SHORT y;
385 #endif
386 } POINTS, *PPOINTS, *LPPOINTS;
388 typedef struct _FILETIME {
389 #ifdef WORDS_BIGENDIAN
390 DWORD dwHighDateTime;
391 DWORD dwLowDateTime;
392 #else
393 DWORD dwLowDateTime;
394 DWORD dwHighDateTime;
395 #endif
396 } FILETIME, *PFILETIME, *LPFILETIME;
397 #define _FILETIME_
399 /* The RECT structure */
400 typedef struct tagRECT
402 LONG left;
403 LONG top;
404 LONG right;
405 LONG bottom;
406 } RECT, *PRECT, *LPRECT;
407 typedef const RECT *LPCRECT;
409 typedef struct _RECTL
411 LONG left;
412 LONG top;
413 LONG right;
414 LONG bottom;
415 } RECTL, *PRECTL, *LPRECTL;
417 typedef const RECTL *LPCRECTL;
419 #ifdef __cplusplus
421 #endif
423 #endif /* _WINDEF_ */