Changed the "this_is_a_syntax_error" error message to a more specific
[wine.git] / include / windef.h
blobf9af7b26fd01d72b1e28a244002936866d37628b
1 /*
2 * Basic types definitions
4 * Copyright 1996 Alexandre Julliard
5 */
7 #ifndef __WINE_WINDEF_H
8 #define __WINE_WINDEF_H
10 #ifdef __WINE__
11 # include "config.h"
12 # undef UNICODE
13 #endif /* __WINE__ */
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
19 /* Misc. constants. */
21 #ifdef FALSE
22 #undef FALSE
23 #endif
24 #define FALSE 0
26 #ifdef TRUE
27 #undef TRUE
28 #endif
29 #define TRUE 1
31 #ifdef NULL
32 #undef NULL
33 #endif
34 #define NULL 0
36 /* Macros to map Winelib names to the correct implementation name */
37 /* depending on __WINE__ and UNICODE macros. */
38 /* Note that Winelib is purely Win32. */
40 #ifdef __WINE__
41 # define WINELIB_NAME_AW(func) \
42 func##_must_be_suffixed_with_W_or_A_in_this_context \
43 func##_must_be_suffixed_with_W_or_A_in_this_context
44 #else /* __WINE__ */
45 # ifdef UNICODE
46 # define WINELIB_NAME_AW(func) func##W
47 # else
48 # define WINELIB_NAME_AW(func) func##A
49 # endif /* UNICODE */
50 #endif /* __WINE__ */
52 #ifdef __WINE__
53 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
54 #else /* __WINE__ */
55 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
56 #endif /* __WINE__ */
58 #ifndef NONAMELESSSTRUCT
59 # if defined(__WINE__) || !defined(_FORCENAMELESSSTRUCT)
60 # define NONAMELESSSTRUCT
61 # endif
62 #endif /* !defined(NONAMELESSSTRUCT) */
64 #ifndef NONAMELESSUNION
65 # if defined(__WINE__) || !defined(_FORCENAMELESSUNION) || !defined(__cplusplus)
66 # define NONAMELESSUNION
67 # endif
68 #endif /* !defined(NONAMELESSUNION) */
70 #ifndef NONAMELESSSTRUCT
71 #define DUMMYSTRUCTNAME
72 #define DUMMYSTRUCTNAME1
73 #define DUMMYSTRUCTNAME2
74 #define DUMMYSTRUCTNAME3
75 #define DUMMYSTRUCTNAME4
76 #define DUMMYSTRUCTNAME5
77 #else /* !defined(NONAMELESSSTRUCT) */
78 #define DUMMYSTRUCTNAME s
79 #define DUMMYSTRUCTNAME1 s1
80 #define DUMMYSTRUCTNAME2 s2
81 #define DUMMYSTRUCTNAME3 s3
82 #define DUMMYSTRUCTNAME4 s4
83 #define DUMMYSTRUCTNAME5 s5
84 #endif /* !defined(NONAMELESSSTRUCT) */
86 #ifndef NONAMELESSUNION
87 #define DUMMYUNIONNAME
88 #define DUMMYUNIONNAME1
89 #define DUMMYUNIONNAME2
90 #define DUMMYUNIONNAME3
91 #define DUMMYUNIONNAME4
92 #define DUMMYUNIONNAME5
93 #else /* !defined(NONAMELESSUNION) */
94 #define DUMMYUNIONNAME u
95 #define DUMMYUNIONNAME1 u1
96 #define DUMMYUNIONNAME2 u2
97 #define DUMMYUNIONNAME3 u3
98 #define DUMMYUNIONNAME4 u4
99 #define DUMMYUNIONNAME5 u5
100 #endif /* !defined(NONAMELESSUNION) */
102 /* Calling conventions definitions */
104 #ifdef __i386__
105 # if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
106 # define __stdcall __attribute__((__stdcall__))
107 # define __cdecl __attribute__((__cdecl__))
108 # define __RESTORE_ES __asm__ __volatile__("pushl %ds\n\tpopl %es")
109 # else
110 # error You need gcc >= 2.7 to build Wine on a 386
111 # endif /* __GNUC__ */
112 #else /* __i386__ */
113 # define __stdcall
114 # define __cdecl
115 # define __RESTORE_ES
116 #endif /* __i386__ */
118 #define CALLBACK __stdcall
119 #define WINAPI __stdcall
120 #define APIPRIVATE __stdcall
121 #define PASCAL __stdcall
122 #define pascal __stdcall
123 #define _pascal __stdcall
124 #define _stdcall __stdcall
125 #define _fastcall __stdcall
126 #define __export __stdcall
127 #define CDECL __cdecl
128 #define _CDECL __cdecl
129 #define cdecl __cdecl
130 #define _cdecl __cdecl
131 #define WINAPIV __cdecl
132 #define APIENTRY WINAPI
134 #define __declspec(x)
135 #define dllimport
136 #define dllexport
138 #define CONST const
140 /* Standard data types. These are the same for emulator and library. */
142 typedef void VOID;
143 typedef short INT16;
144 typedef unsigned short UINT16;
145 typedef int INT;
146 typedef unsigned int UINT;
147 typedef unsigned short WORD;
148 typedef unsigned long DWORD;
149 typedef unsigned long ULONG;
150 typedef unsigned char BYTE;
151 typedef long LONG;
152 typedef short SHORT;
153 typedef unsigned short USHORT;
154 typedef char CHAR;
155 typedef unsigned char UCHAR;
156 /* Some systems might have wchar_t, but we really need 16 bit characters */
157 typedef unsigned short WCHAR;
158 typedef unsigned short BOOL16;
159 typedef int BOOL;
160 typedef double DATE;
161 typedef double DOUBLE;
162 typedef double LONGLONG;
163 typedef double ULONGLONG;
165 /* FIXME: Wine does not compile with strict on, therefore strict
166 * handles are presently only usable on machines where sizeof(UINT) ==
167 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
168 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
169 * they exist as UINTs but to the Winelib user who turns on strict,
170 * they exist as void*. If there is a size difference between UINT and
171 * void* then things get ugly. */
172 #ifdef STRICT
173 typedef UINT16 HANDLE16;
174 typedef VOID* HANDLE;
175 #else
176 typedef UINT16 HANDLE16;
177 typedef UINT HANDLE;
178 #endif
180 typedef HANDLE16 *LPHANDLE16;
181 typedef HANDLE *LPHANDLE;
183 /* Integer types. These are the same for emulator and library. */
184 typedef UINT16 WPARAM16;
185 typedef UINT WPARAM;
186 typedef LONG LPARAM;
187 typedef LONG HRESULT;
188 typedef LONG LRESULT;
189 typedef WORD ATOM;
190 typedef WORD CATCHBUF[9];
191 typedef WORD *LPCATCHBUF;
192 typedef HANDLE HHOOK;
193 typedef HANDLE HMONITOR;
194 typedef DWORD LCID;
195 typedef WORD LANGID;
196 typedef DWORD LCTYPE;
197 typedef float FLOAT;
199 /* Pointers types. These are the same for emulator and library. */
200 /* winnt types */
201 typedef VOID *PVOID;
202 typedef const void *PCVOID;
203 typedef CHAR *PCHAR;
204 typedef UCHAR *PUCHAR;
205 typedef BYTE *PBYTE;
206 typedef WORD *PWORD;
207 typedef ULONG *PULONG;
208 typedef LONG *PLONG;
209 typedef DWORD *PDWORD;
210 /* common win32 types */
211 typedef CHAR *LPSTR;
212 typedef CHAR *PSTR;
213 typedef const CHAR *LPCSTR;
214 typedef const CHAR *PCSTR;
215 typedef WCHAR *LPWSTR;
216 typedef WCHAR *PWSTR;
217 typedef const WCHAR *LPCWSTR;
218 typedef const WCHAR *PCWSTR;
219 typedef BYTE *LPBYTE;
220 typedef WORD *LPWORD;
221 typedef DWORD *LPDWORD;
222 typedef LONG *LPLONG;
223 typedef VOID *LPVOID;
224 typedef const VOID *LPCVOID;
225 typedef INT16 *LPINT16;
226 typedef UINT16 *LPUINT16;
227 typedef INT *PINT;
228 typedef INT *LPINT;
229 typedef UINT *PUINT;
230 typedef UINT *LPUINT;
231 typedef FLOAT *PFLOAT;
232 typedef FLOAT *LPFLOAT;
233 typedef BOOL *PBOOL;
234 typedef BOOL *LPBOOL;
236 /* Special case: a segmented pointer is just a pointer in the user's code. */
238 #ifdef __WINE__
239 typedef DWORD SEGPTR;
240 #else
241 typedef void* SEGPTR;
242 #endif /* __WINE__ */
244 /* Handle types that exist both in Win16 and Win32. */
246 #ifdef STRICT
247 #define DECLARE_HANDLE(a) \
248 typedef HANDLE16 a##16; \
249 typedef a##16 *P##a##16; \
250 typedef a##16 *NP##a##16; \
251 typedef a##16 *LP##a##16; \
252 typedef struct a##__ { int unused; } *a; \
253 typedef a *P##a; \
254 typedef a *LP##a
255 #else /*STRICT*/
256 #define DECLARE_HANDLE(a) \
257 typedef HANDLE16 a##16; \
258 typedef a##16 *P##a##16; \
259 typedef a##16 *NP##a##16; \
260 typedef a##16 *LP##a##16; \
261 typedef HANDLE a; \
262 typedef a *P##a; \
263 typedef a *LP##a
264 #endif /*STRICT*/
266 DECLARE_HANDLE(HACMDRIVERID);
267 DECLARE_HANDLE(HACMDRIVER);
268 DECLARE_HANDLE(HACMOBJ);
269 DECLARE_HANDLE(HACMSTREAM);
270 DECLARE_HANDLE(HMETAFILEPICT);
272 DECLARE_HANDLE(HACCEL);
273 DECLARE_HANDLE(HBITMAP);
274 DECLARE_HANDLE(HBRUSH);
275 DECLARE_HANDLE(HCOLORSPACE);
276 DECLARE_HANDLE(HCURSOR);
277 DECLARE_HANDLE(HDC);
278 DECLARE_HANDLE(HDROP);
279 DECLARE_HANDLE(HDRVR);
280 DECLARE_HANDLE(HDWP);
281 DECLARE_HANDLE(HENHMETAFILE);
282 DECLARE_HANDLE(HFILE);
283 DECLARE_HANDLE(HFONT);
284 DECLARE_HANDLE(HICON);
285 DECLARE_HANDLE(HINSTANCE);
286 DECLARE_HANDLE(HKEY);
287 DECLARE_HANDLE(HMENU);
288 DECLARE_HANDLE(HMETAFILE);
289 DECLARE_HANDLE(HMIDI);
290 DECLARE_HANDLE(HMIDIIN);
291 DECLARE_HANDLE(HMIDIOUT);
292 DECLARE_HANDLE(HMIDISTRM);
293 DECLARE_HANDLE(HMIXER);
294 DECLARE_HANDLE(HMIXEROBJ);
295 DECLARE_HANDLE(HMMIO);
296 DECLARE_HANDLE(HPALETTE);
297 DECLARE_HANDLE(HPEN);
298 DECLARE_HANDLE(HQUEUE);
299 DECLARE_HANDLE(HRGN);
300 DECLARE_HANDLE(HRSRC);
301 DECLARE_HANDLE(HTASK);
302 DECLARE_HANDLE(HWAVE);
303 DECLARE_HANDLE(HWAVEIN);
304 DECLARE_HANDLE(HWAVEOUT);
305 DECLARE_HANDLE(HWINSTA);
306 DECLARE_HANDLE(HDESK);
307 DECLARE_HANDLE(HWND);
308 DECLARE_HANDLE(HKL);
309 DECLARE_HANDLE(HIC);
310 DECLARE_HANDLE(HRASCONN);
311 #undef DECLARE_HANDLE
313 /* Handle types that must remain interchangeable even with strict on */
315 typedef HINSTANCE16 HMODULE16;
316 typedef HINSTANCE HMODULE;
317 typedef HANDLE16 HGDIOBJ16;
318 typedef HANDLE16 HGLOBAL16;
319 typedef HANDLE16 HLOCAL16;
320 typedef HANDLE HGDIOBJ;
321 typedef HANDLE HGLOBAL;
322 typedef HANDLE HLOCAL;
324 /* Callback function pointers types */
326 typedef BOOL (CALLBACK* DATEFMT_ENUMPROCA)(LPSTR);
327 typedef BOOL (CALLBACK* DATEFMT_ENUMPROCW)(LPWSTR);
328 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC)
329 typedef BOOL16 (CALLBACK *DLGPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
330 typedef BOOL (CALLBACK *DLGPROC)(HWND,UINT,WPARAM,LPARAM);
331 typedef LRESULT (CALLBACK *DRIVERPROC16)(DWORD,HDRVR16,UINT16,LPARAM,LPARAM);
332 typedef LRESULT (CALLBACK *DRIVERPROC)(DWORD,HDRVR,UINT,LPARAM,LPARAM);
333 typedef INT16 (CALLBACK *EDITWORDBREAKPROC16)(LPSTR,INT16,INT16,INT16);
334 typedef INT (CALLBACK *EDITWORDBREAKPROCA)(LPSTR,INT,INT,INT);
335 typedef INT (CALLBACK *EDITWORDBREAKPROCW)(LPWSTR,INT,INT,INT);
336 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC)
337 typedef LRESULT (CALLBACK *FARPROC16)();
338 typedef LRESULT (CALLBACK *FARPROC)();
339 typedef INT16 (CALLBACK *PROC16)();
340 typedef INT (CALLBACK *PROC)();
341 typedef BOOL16 (CALLBACK *GRAYSTRINGPROC16)(HDC16,LPARAM,INT16);
342 typedef BOOL (CALLBACK *GRAYSTRINGPROC)(HDC,LPARAM,INT);
343 typedef LRESULT (CALLBACK *HOOKPROC16)(INT16,WPARAM16,LPARAM);
344 typedef LRESULT (CALLBACK *HOOKPROC)(INT,WPARAM,LPARAM);
345 typedef BOOL16 (CALLBACK *PROPENUMPROC16)(HWND16,SEGPTR,HANDLE16);
346 typedef BOOL (CALLBACK *PROPENUMPROCA)(HWND,LPCSTR,HANDLE);
347 typedef BOOL (CALLBACK *PROPENUMPROCW)(HWND,LPCWSTR,HANDLE);
348 DECL_WINELIB_TYPE_AW(PROPENUMPROC)
349 typedef BOOL (CALLBACK *PROPENUMPROCEXA)(HWND,LPCSTR,HANDLE,LPARAM);
350 typedef BOOL (CALLBACK *PROPENUMPROCEXW)(HWND,LPCWSTR,HANDLE,LPARAM);
351 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX)
352 typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCA)(LPSTR);
353 typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCW)(LPWSTR);
354 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC)
355 typedef VOID (CALLBACK *TIMERPROC16)(HWND16,UINT16,UINT16,DWORD);
356 typedef VOID (CALLBACK *TIMERPROC)(HWND,UINT,UINT,DWORD);
357 typedef LRESULT (CALLBACK *WNDENUMPROC16)(HWND16,LPARAM);
358 typedef LRESULT (CALLBACK *WNDENUMPROC)(HWND,LPARAM);
359 typedef LRESULT (CALLBACK *WNDPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
360 typedef LRESULT (CALLBACK *WNDPROC)(HWND,UINT,WPARAM,LPARAM);
362 /* Define some empty macros for compatibility with Windows code. */
364 #ifndef __WINE__
365 #define NEAR
366 #define FAR
367 #define near
368 #define far
369 #define _near
370 #define _far
371 #define IN
372 #define OUT
373 #define OPTIONAL
374 #endif /* __WINE__ */
376 /* Macro for structure packing. */
378 #ifdef __GNUC__
379 #define WINE_PACKED __attribute__ ((packed))
380 #define WINE_UNUSED __attribute__ ((unused))
381 #else
382 #define WINE_PACKED /* nothing */
383 #define WINE_UNUSED /* nothing */
384 #endif
386 /* Macros to split words and longs. */
388 #define LOBYTE(w) ((BYTE)(WORD)(w))
389 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
391 #define LOWORD(l) ((WORD)(DWORD)(l))
392 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
394 #define SLOWORD(l) ((INT16)(LONG)(l))
395 #define SHIWORD(l) ((INT16)((LONG)(l) >> 16))
397 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
398 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
399 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
400 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
401 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
402 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
404 #define SELECTOROF(ptr) (HIWORD(ptr))
405 #define OFFSETOF(ptr) (LOWORD(ptr))
407 #ifdef __WINE__
408 /* macros to set parts of a DWORD (not in the Windows API) */
409 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
410 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
411 #define SET_HIBYTE(dw,val) ((dw) = ((dw) & 0xffff00ff) | (LOWORD(val) & 0xff00))
412 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
413 #endif
415 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
416 /* Note: These macros are semantically broken, at least for wrc. wrc
417 spits out data in the platform's current binary format, *not* in
418 little-endian format. These macros are used throughout the resource
419 code to load and store data to the resources. Since it is unlikely
420 that we'll ever be dealing with little-endian resource data, the
421 byte-swapping nature of these macros has been disabled. Rather than
422 remove the use of these macros from the resource loading code, the
423 macros have simply been disabled. In the future, someone may want
424 to reactivate these macros for other purposes. In that case, the
425 resource code will have to be modified to use different macros. */
427 #if 1
428 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
429 #define GET_WORD(ptr) (*(WORD *)(ptr))
430 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
431 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
432 #else
433 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
434 *((BYTE *)(ptr) + 1) = HIBYTE(w))
435 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
436 (WORD)(*((BYTE *)(ptr)+1) << 8)))
437 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
438 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
439 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
440 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
441 #endif /* 1 */
443 /* MIN and MAX macros */
445 #ifdef MAX
446 #undef MAX
447 #endif
448 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
450 #ifdef MIN
451 #undef MIN
452 #endif
453 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
455 #define __max(a,b) MAX(a,b)
456 #define __min(a,b) MIN(a,b)
457 #ifndef max
458 #define max(a,b) MAX(a,b)
459 #endif
460 #ifndef min
461 #define min(a,b) MIN(a,b)
462 #endif
464 #define _MAX_PATH 260
465 #define MAX_PATH 260
466 #define _MAX_DRIVE 3
467 #define _MAX_DIR 256
468 #define _MAX_FNAME 255
469 #define _MAX_EXT 256
471 #define HFILE_ERROR16 ((HFILE16)-1)
472 #define HFILE_ERROR ((HFILE)-1)
474 /* The SIZE structure */
476 typedef struct
478 INT16 cx;
479 INT16 cy;
480 } SIZE16, *PSIZE16, *LPSIZE16;
482 typedef struct tagSIZE
484 INT cx;
485 INT cy;
486 } SIZE, *PSIZE, *LPSIZE;
489 typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;
491 #define CONV_SIZE16TO32(s16,s32) \
492 ((s32)->cx = (INT)(s16)->cx, (s32)->cy = (INT)(s16)->cy)
493 #define CONV_SIZE32TO16(s32,s16) \
494 ((s16)->cx = (INT16)(s32)->cx, (s16)->cy = (INT16)(s32)->cy)
496 /* The POINT structure */
498 typedef struct
500 INT16 x;
501 INT16 y;
502 } POINT16, *PPOINT16, *LPPOINT16;
504 typedef struct tagPOINT
506 LONG x;
507 LONG y;
508 } POINT, *PPOINT, *LPPOINT;
510 typedef struct _POINTL
512 LONG x;
513 LONG y;
514 } POINTL;
516 #define CONV_POINT16TO32(p16,p32) \
517 ((p32)->x = (INT)(p16)->x, (p32)->y = (INT)(p16)->y)
518 #define CONV_POINT32TO16(p32,p16) \
519 ((p16)->x = (INT16)(p32)->x, (p16)->y = (INT16)(p32)->y)
521 #define MAKEPOINT16(l) (*((POINT16 *)&(l)))
523 /* The POINTS structure */
525 typedef struct tagPOINTS
527 SHORT x;
528 SHORT y;
529 } POINTS, *PPOINTS, *LPPOINTS;
532 #define MAKEPOINTS(l) (*((POINTS *)&(l)))
535 /* The RECT structure */
537 typedef struct
539 INT16 left;
540 INT16 top;
541 INT16 right;
542 INT16 bottom;
543 } RECT16, *LPRECT16;
545 typedef struct tagRECT
547 INT left;
548 INT top;
549 INT right;
550 INT bottom;
551 } RECT, *PRECT, *LPRECT;
552 typedef const RECT *LPCRECT;
555 typedef struct tagRECTL
557 LONG left;
558 LONG top;
559 LONG right;
560 LONG bottom;
561 } RECTL, *PRECTL, *LPRECTL;
563 typedef const RECTL *LPCRECTL;
565 #define CONV_RECT16TO32(r16,r32) \
566 ((r32)->left = (INT)(r16)->left, (r32)->top = (INT)(r16)->top, \
567 (r32)->right = (INT)(r16)->right, (r32)->bottom = (INT)(r16)->bottom)
568 #define CONV_RECT32TO16(r32,r16) \
569 ((r16)->left = (INT16)(r32)->left, (r16)->top = (INT16)(r32)->top, \
570 (r16)->right = (INT16)(r32)->right, (r16)->bottom = (INT16)(r32)->bottom)
572 #ifdef __cplusplus
574 #endif
576 #endif /* __WINE_WINDEF_H */