comdlg32: Avoid crash in RemoveControlItem.
[wine.git] / include / windef.h
blob28aa7d6a237b27b6cc6a36c6fab61056fa487619
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 #ifndef __has_attribute
35 #define __has_attribute(x) 0
36 #endif
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
42 /* Calling conventions definitions */
44 #if (defined(__x86_64__) || defined(__powerpc64__) || defined(__aarch64__)) && !defined(_WIN64)
45 #define _WIN64
46 #endif
48 #ifndef _WIN64
49 # if defined(__i386__) && !defined(_X86_)
50 # define _X86_
51 # endif
52 # if defined(_X86_) && !defined(__i386__)
53 # define __i386__
54 # endif
55 #endif
57 #ifdef WINE_UNIX_LIB
58 # define __stdcall
59 # define __cdecl
60 # define __fastcall
61 #elif !defined(_MSC_VER) && !defined(__MINGW32__)
62 # undef __stdcall
63 # ifdef __i386__
64 # ifdef __GNUC__
65 # if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || defined(__APPLE__)
66 # define __stdcall __attribute__((__stdcall__)) __attribute__((__force_align_arg_pointer__))
67 # else
68 # define __stdcall __attribute__((__stdcall__))
69 # endif
70 # else
71 # error You need to define __stdcall for your compiler
72 # endif
73 # elif defined(__x86_64__) && defined (__GNUC__)
74 # if __has_attribute(__force_align_arg_pointer__)
75 # define __stdcall __attribute__((ms_abi)) __attribute__((__force_align_arg_pointer__))
76 # else
77 # define __stdcall __attribute__((ms_abi))
78 # endif
79 # elif defined(__arm__) && defined (__GNUC__) && !defined(__SOFTFP__) && !defined(__CYGWIN__)
80 # define __stdcall __attribute__((pcs("aapcs-vfp")))
81 # elif defined(__aarch64__) && defined (__GNUC__) && __has_attribute(ms_abi)
82 # define __stdcall __attribute__((ms_abi))
83 # else /* __i386__ */
84 # define __stdcall
85 # endif /* __i386__ */
86 # undef __cdecl
87 # if defined(__i386__) && defined(__GNUC__)
88 # if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || defined(__APPLE__)
89 # define __cdecl __attribute__((__cdecl__)) __attribute__((__force_align_arg_pointer__))
90 # else
91 # define __cdecl __attribute__((__cdecl__))
92 # endif
93 # else
94 # define __cdecl __stdcall
95 # endif
96 # ifndef __fastcall
97 # define __fastcall __stdcall
98 # endif
99 # ifndef __thiscall
100 # define __thiscall __stdcall
101 # endif
102 #endif /* _MSC_VER || __MINGW32__ */
104 #ifndef __ms_va_list
105 # if (defined(__x86_64__) || (defined(__aarch64__) && __has_attribute(ms_abi))) && defined (__GNUC__)
106 # define __ms_va_list __builtin_ms_va_list
107 # define __ms_va_start(list,arg) __builtin_ms_va_start(list,arg)
108 # define __ms_va_end(list) __builtin_ms_va_end(list)
109 # define __ms_va_copy(dest,src) __builtin_ms_va_copy(dest,src)
110 # else
111 # define __ms_va_list va_list
112 # define __ms_va_start(list,arg) va_start(list,arg)
113 # define __ms_va_end(list) va_end(list)
114 # ifdef va_copy
115 # define __ms_va_copy(dest,src) va_copy(dest,src)
116 # else
117 # define __ms_va_copy(dest,src) ((dest) = (src))
118 # endif
119 # endif
120 #endif
122 #if defined(__arm__) && defined (__GNUC__) && !defined(__SOFTFP__) && !defined(__MINGW32__) && !defined(__CYGWIN__)
123 # define WINAPIV __attribute__((pcs("aapcs")))
124 #else
125 # define WINAPIV __cdecl
126 #endif
128 #ifdef __WINESRC__
129 #define __ONLY_IN_WINELIB(x) do_not_use_this_in_wine
130 #else
131 #define __ONLY_IN_WINELIB(x) x
132 #endif
134 #ifndef _MSC_VER
135 #ifndef _stdcall
136 #define _stdcall __ONLY_IN_WINELIB(__stdcall)
137 #endif
138 #ifndef _fastcall
139 #define _fastcall __ONLY_IN_WINELIB(__stdcall)
140 #endif
141 #ifndef __fastcall
142 #define __fastcall __ONLY_IN_WINELIB(__stdcall)
143 #endif
144 #ifndef cdecl
145 #define cdecl __ONLY_IN_WINELIB(__cdecl)
146 #endif
147 #ifndef _cdecl
148 #define _cdecl __ONLY_IN_WINELIB(__cdecl)
149 #endif
150 #endif /* _MSC_VER */
152 #ifndef pascal
153 #define pascal __ONLY_IN_WINELIB(__stdcall)
154 #endif
155 #ifndef _pascal
156 #define _pascal __ONLY_IN_WINELIB(__stdcall)
157 #endif
158 #ifndef __export
159 #define __export __ONLY_IN_WINELIB(__stdcall)
160 #endif
161 #ifndef near
162 #define near __ONLY_IN_WINELIB(/* nothing */)
163 #endif
164 #ifndef far
165 #define far __ONLY_IN_WINELIB(/* nothing */)
166 #endif
167 #ifndef _near
168 #define _near __ONLY_IN_WINELIB(/* nothing */)
169 #endif
170 #ifndef _far
171 #define _far __ONLY_IN_WINELIB(/* nothing */)
172 #endif
173 #ifndef NEAR
174 #define NEAR __ONLY_IN_WINELIB(/* nothing */)
175 #endif
176 #ifndef FAR
177 #define FAR __ONLY_IN_WINELIB(/* nothing */)
178 #endif
180 #ifndef _MSC_VER
181 # ifndef _declspec
182 # define _declspec(x) __ONLY_IN_WINELIB(/* nothing */)
183 # endif
184 # ifndef __declspec
185 # define __declspec(x) __ONLY_IN_WINELIB(/* nothing */)
186 # endif
187 #endif
189 #ifdef _MSC_VER
190 # define inline __inline
191 #endif
193 #define CALLBACK __stdcall
194 #define WINAPI __stdcall
195 #define APIPRIVATE __stdcall
196 #define PASCAL __stdcall
197 #define CDECL __cdecl
198 #define _CDECL __cdecl
199 #define APIENTRY WINAPI
200 #define CONST __ONLY_IN_WINELIB(const)
202 /* Misc. constants. */
204 #undef NULL
205 #ifdef __cplusplus
206 #define NULL 0
207 #else
208 #define NULL ((void*)0)
209 #endif
211 #ifdef FALSE
212 #undef FALSE
213 #endif
214 #define FALSE 0
216 #ifdef TRUE
217 #undef TRUE
218 #endif
219 #define TRUE 1
221 #ifndef IN
222 #define IN
223 #endif
225 #ifndef OUT
226 #define OUT
227 #endif
229 #ifndef OPTIONAL
230 #define OPTIONAL
231 #endif
233 /* Standard data types */
235 #ifndef BASETYPES
236 #define BASETYPES
237 typedef unsigned char UCHAR, *PUCHAR;
238 typedef unsigned short USHORT, *PUSHORT;
239 #if !defined(__LP64__) && !defined(WINE_NO_LONG_TYPES)
240 typedef unsigned long ULONG, *PULONG;
241 #else
242 typedef unsigned int ULONG, *PULONG;
243 #endif
244 #endif
246 typedef void *LPVOID;
247 typedef const void *LPCVOID;
248 typedef int BOOL, *PBOOL, *LPBOOL;
249 typedef unsigned char BYTE, *PBYTE, *LPBYTE;
250 typedef unsigned short WORD, *PWORD, *LPWORD;
251 typedef int INT, *PINT, *LPINT;
252 typedef unsigned int UINT, *PUINT;
253 typedef float FLOAT, *PFLOAT;
254 typedef char *PSZ;
255 #if !defined(__LP64__) && !defined(WINE_NO_LONG_TYPES)
256 typedef long *LPLONG;
257 typedef unsigned long DWORD, *PDWORD, *LPDWORD;
258 #else
259 typedef int *LPLONG;
260 typedef unsigned int DWORD, *PDWORD, *LPDWORD;
261 #endif
263 /* Macros to map Winelib names to the correct implementation name */
264 /* Note that Winelib is purely Win32. */
266 #ifdef __WINESRC__
267 #define WINE_NO_UNICODE_MACROS 1
268 #define WINE_STRICT_PROTOTYPES 1
269 #endif
271 #ifdef WINE_NO_UNICODE_MACROS
272 # define WINELIB_NAME_AW(func) \
273 func##_must_be_suffixed_with_W_or_A_in_this_context \
274 func##_must_be_suffixed_with_W_or_A_in_this_context
275 #else /* WINE_NO_UNICODE_MACROS */
276 # ifdef UNICODE
277 # define WINELIB_NAME_AW(func) func##W
278 # else
279 # define WINELIB_NAME_AW(func) func##A
280 # endif
281 #endif /* WINE_NO_UNICODE_MACROS */
283 #ifdef WINE_NO_UNICODE_MACROS
284 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
285 #else
286 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
287 #endif
289 #include <winnt.h>
291 /* Polymorphic types */
293 typedef UINT_PTR WPARAM;
294 typedef LONG_PTR LPARAM;
295 typedef LONG_PTR LRESULT;
297 /* Integer types */
299 typedef WORD ATOM;
300 typedef DWORD COLORREF, *LPCOLORREF;
303 /* Handle types */
305 typedef int HFILE;
306 DECLARE_HANDLE(DPI_AWARENESS_CONTEXT);
307 DECLARE_HANDLE(HACCEL);
308 DECLARE_HANDLE(HBITMAP);
309 DECLARE_HANDLE(HBRUSH);
310 DECLARE_HANDLE(HCOLORSPACE);
311 DECLARE_HANDLE(HDC);
312 DECLARE_HANDLE(HDESK);
313 DECLARE_HANDLE(HENHMETAFILE);
314 DECLARE_HANDLE(HFONT);
315 DECLARE_HANDLE(HGLRC);
316 DECLARE_HANDLE(HHOOK);
317 DECLARE_HANDLE(HICON);
318 DECLARE_HANDLE(HINSTANCE);
319 DECLARE_HANDLE(HKEY);
320 typedef HKEY *PHKEY;
321 DECLARE_HANDLE(HKL);
322 DECLARE_HANDLE(HMENU);
323 DECLARE_HANDLE(HMETAFILE);
324 DECLARE_HANDLE(HMONITOR);
325 DECLARE_HANDLE(HPALETTE);
326 DECLARE_HANDLE(HPEN);
327 DECLARE_HANDLE(HRGN);
328 DECLARE_HANDLE(HRSRC);
329 DECLARE_HANDLE(HTASK);
330 DECLARE_HANDLE(HWINEVENTHOOK);
331 DECLARE_HANDLE(HWINSTA);
332 DECLARE_HANDLE(HWND);
334 /* Handle types that must remain interchangeable even with strict on */
336 typedef HINSTANCE HMODULE;
337 typedef HANDLE HGDIOBJ;
338 typedef HANDLE HGLOBAL;
339 typedef HANDLE HLOCAL;
340 typedef HANDLE GLOBALHANDLE;
341 typedef HANDLE LOCALHANDLE;
342 typedef HICON HCURSOR;
344 /* Callback function pointers types */
346 #ifdef WINE_STRICT_PROTOTYPES
347 typedef INT_PTR (CALLBACK *FARPROC)(void);
348 typedef INT_PTR (CALLBACK *NEARPROC)(void);
349 typedef INT_PTR (CALLBACK *PROC)(void);
350 #else
351 typedef INT_PTR (CALLBACK *FARPROC)();
352 typedef INT_PTR (CALLBACK *NEARPROC)();
353 typedef INT_PTR (CALLBACK *PROC)();
354 #endif
356 /* Macros to split words and longs. */
358 #define LOBYTE(w) ((BYTE)((DWORD_PTR)(w) & 0xFF))
359 #define HIBYTE(w) ((BYTE)((DWORD_PTR)(w) >> 8))
361 #define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xFFFF))
362 #define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16))
364 #define MAKEWORD(low,high) ((WORD)(((BYTE)((DWORD_PTR)(low) & 0xFF)) | ((WORD)((BYTE)((DWORD_PTR)(high) & 0xFF))) << 8))
365 #define MAKELONG(low,high) ((LONG)(((WORD)((DWORD_PTR)(low) & 0xFFFF)) | ((DWORD)((WORD)((DWORD_PTR)(high) & 0xFFFF))) << 16))
367 /* min and max macros */
368 #ifndef NOMINMAX
369 #ifndef max
370 #define max(a,b) (((a) > (b)) ? (a) : (b))
371 #endif
372 #ifndef min
373 #define min(a,b) (((a) < (b)) ? (a) : (b))
374 #endif
375 #endif /* NOMINMAX */
377 #ifdef MAX_PATH /* Work-around for Mingw */
378 #undef MAX_PATH
379 #endif /* MAX_PATH */
381 #define MAX_PATH 260
382 #define HFILE_ERROR ((HFILE)-1)
384 /* The SIZE structure */
385 typedef struct tagSIZE
387 LONG cx;
388 LONG cy;
389 } SIZE, *PSIZE, *LPSIZE;
391 typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;
393 /* The POINT structure */
394 typedef struct tagPOINT
396 LONG x;
397 LONG y;
398 } POINT, *PPOINT, *LPPOINT;
400 typedef struct _POINTL
402 LONG x;
403 LONG y;
404 } POINTL, *PPOINTL;
406 /* The POINTS structure */
408 typedef struct tagPOINTS
410 #ifdef WORDS_BIGENDIAN
411 SHORT y;
412 SHORT x;
413 #else
414 SHORT x;
415 SHORT y;
416 #endif
417 } POINTS, *PPOINTS, *LPPOINTS;
419 typedef struct _FILETIME {
420 #ifdef WORDS_BIGENDIAN
421 DWORD dwHighDateTime;
422 DWORD dwLowDateTime;
423 #else
424 DWORD dwLowDateTime;
425 DWORD dwHighDateTime;
426 #endif
427 } FILETIME, *PFILETIME, *LPFILETIME;
428 #define _FILETIME_
430 /* The RECT structure */
431 typedef struct tagRECT
433 LONG left;
434 LONG top;
435 LONG right;
436 LONG bottom;
437 } RECT, *PRECT, *LPRECT;
438 typedef const RECT *LPCRECT;
440 typedef struct _RECTL
442 LONG left;
443 LONG top;
444 LONG right;
445 LONG bottom;
446 } RECTL, *PRECTL, *LPRECTL;
448 typedef const RECTL *LPCRECTL;
450 /* DPI awareness */
451 typedef enum DPI_AWARENESS
453 DPI_AWARENESS_INVALID = -1,
454 DPI_AWARENESS_UNAWARE = 0,
455 DPI_AWARENESS_SYSTEM_AWARE,
456 DPI_AWARENESS_PER_MONITOR_AWARE
457 } DPI_AWARENESS;
459 #define DPI_AWARENESS_CONTEXT_UNAWARE ((DPI_AWARENESS_CONTEXT)-1)
460 #define DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ((DPI_AWARENESS_CONTEXT)-2)
461 #define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ((DPI_AWARENESS_CONTEXT)-3)
462 #define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((DPI_AWARENESS_CONTEXT)-4)
463 #define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED ((DPI_AWARENESS_CONTEXT)-5)
465 #ifdef __cplusplus
467 #endif
469 #endif /* _WINDEF_ */