2 * Basic types definitions
4 * Copyright 1996 Alexandre Julliard
7 #ifndef __WINE_WINDEF_H
8 #define __WINE_WINDEF_H
18 /* Misc. constants. */
37 /* Macros to map Winelib names to the correct implementation name */
38 /* depending on __WINE__ and UNICODE macros. */
39 /* Note that Winelib is purely Win32. */
42 # define WINELIB_NAME_AW(func) \
43 func##_must_be_suffixed_with_W_or_A_in_this_context \
44 func##_must_be_suffixed_with_W_or_A_in_this_context
47 # define WINELIB_NAME_AW(func) func##W
49 # define WINELIB_NAME_AW(func) func##A
54 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
56 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
60 # define NONAMELESSSTRUCT
61 # define NONAMELESSUNION
63 /* Anonymous struct support starts with gcc/g++ 2.96 */
64 # if !defined(NONAMELESSSTRUCT) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ < 96)))
65 # define NONAMELESSSTRUCT
67 /* Anonymous unions support starts with gcc 2.96/g++ 2.95 */
68 # if !defined(NONAMELESSUNION) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ < 95) || ((__GNUC_MINOR__ == 95) && !defined(__cplusplus)))))
69 # define NONAMELESSUNION
73 #ifndef NONAMELESSSTRUCT
74 #define DUMMYSTRUCTNAME
75 #define DUMMYSTRUCTNAME1
76 #define DUMMYSTRUCTNAME2
77 #define DUMMYSTRUCTNAME3
78 #define DUMMYSTRUCTNAME4
79 #define DUMMYSTRUCTNAME5
80 #else /* !defined(NONAMELESSSTRUCT) */
81 #define DUMMYSTRUCTNAME s
82 #define DUMMYSTRUCTNAME1 s1
83 #define DUMMYSTRUCTNAME2 s2
84 #define DUMMYSTRUCTNAME3 s3
85 #define DUMMYSTRUCTNAME4 s4
86 #define DUMMYSTRUCTNAME5 s5
87 #endif /* !defined(NONAMELESSSTRUCT) */
89 #ifndef NONAMELESSUNION
90 #define DUMMYUNIONNAME
91 #define DUMMYUNIONNAME1
92 #define DUMMYUNIONNAME2
93 #define DUMMYUNIONNAME3
94 #define DUMMYUNIONNAME4
95 #define DUMMYUNIONNAME5
96 #define DUMMYUNIONNAME6
97 #define DUMMYUNIONNAME7
98 #define DUMMYUNIONNAME8
99 #else /* !defined(NONAMELESSUNION) */
100 #define DUMMYUNIONNAME u
101 #define DUMMYUNIONNAME1 u1
102 #define DUMMYUNIONNAME2 u2
103 #define DUMMYUNIONNAME3 u3
104 #define DUMMYUNIONNAME4 u4
105 #define DUMMYUNIONNAME5 u5
106 #define DUMMYUNIONNAME6 u6
107 #define DUMMYUNIONNAME7 u7
108 #define DUMMYUNIONNAME8 u8
109 #endif /* !defined(NONAMELESSUNION) */
111 /* Calling conventions definitions */
117 # if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
118 # define __stdcall __attribute__((__stdcall__))
119 # define __cdecl __attribute__((__cdecl__))
121 # error You need gcc >= 2.7 to build Wine on a 386
122 # endif /* __GNUC__ */
126 #endif /* __i386__ */
128 #define CALLBACK __stdcall
129 #define WINAPI __stdcall
130 #define APIPRIVATE __stdcall
131 #define PASCAL __stdcall
132 #define pascal __stdcall
133 #define _pascal __stdcall
134 #define _stdcall __stdcall
135 #define _fastcall __stdcall
136 #define __fastcall __stdcall
137 #define __export __stdcall
138 #define CDECL __cdecl
139 #define _CDECL __cdecl
140 #define cdecl __cdecl
141 #define _cdecl __cdecl
142 #define WINAPIV __cdecl
143 #define APIENTRY WINAPI
146 #define __declspec(x)
150 /* Standard data types. These are the same for emulator and library. */
154 typedef unsigned int UINT
;
155 typedef unsigned short WORD
;
156 typedef unsigned long DWORD
;
157 typedef unsigned long ULONG
;
158 typedef unsigned char BYTE
;
161 typedef unsigned short USHORT
;
163 typedef unsigned char UCHAR
;
164 /* Some systems might have wchar_t, but we really need 16 bit characters */
165 typedef unsigned short WCHAR
;
168 typedef double DOUBLE
;
170 /* FIXME: Wine does not compile with strict on, therefore strict
171 * handles are presently only usable on machines where sizeof(UINT) ==
172 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
173 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
174 * they exist as UINTs but to the Winelib user who turns on strict,
175 * they exist as void*. If there is a size difference between UINT and
176 * void* then things get ugly. */
178 typedef VOID
* HANDLE
;
184 typedef HANDLE
*LPHANDLE
;
186 /* Integer types. These are the same for emulator and library. */
189 typedef LONG HRESULT
;
190 typedef LONG LRESULT
;
192 typedef WORD CATCHBUF
[9];
193 typedef WORD
*LPCATCHBUF
;
194 typedef HANDLE HHOOK
;
195 typedef HANDLE HMONITOR
;
200 /* Pointers types. These are the same for emulator and library. */
203 typedef const void *PCVOID
;
205 typedef UCHAR
*PUCHAR
;
208 typedef USHORT
*PUSHORT
;
209 typedef SHORT
*PSHORT
;
210 typedef ULONG
*PULONG
;
212 typedef DWORD
*PDWORD
;
213 /* common win32 types */
216 typedef const CHAR
*LPCSTR
;
217 typedef const CHAR
*PCSTR
;
218 typedef WCHAR
*LPWSTR
;
219 typedef WCHAR
*PWSTR
;
220 typedef const WCHAR
*LPCWSTR
;
221 typedef const WCHAR
*PCWSTR
;
222 typedef BYTE
*LPBYTE
;
223 typedef WORD
*LPWORD
;
224 typedef DWORD
*LPDWORD
;
225 typedef LONG
*LPLONG
;
226 typedef VOID
*LPVOID
;
227 typedef const VOID
*LPCVOID
;
231 typedef UINT
*LPUINT
;
232 typedef FLOAT
*PFLOAT
;
233 typedef FLOAT
*LPFLOAT
;
235 typedef BOOL
*LPBOOL
;
237 /* Special case: a segmented pointer is just a pointer in the user's code. */
240 typedef DWORD SEGPTR
;
242 typedef void* SEGPTR
;
243 #endif /* __WINE__ */
245 /* Handle types that exist both in Win16 and Win32. */
248 #define DECLARE_HANDLE(a) \
249 typedef struct a##__ { int unused; } *a; \
253 #define DECLARE_HANDLE(a) \
259 DECLARE_HANDLE(HACMDRIVERID
);
260 DECLARE_HANDLE(HACMDRIVER
);
261 DECLARE_HANDLE(HACMOBJ
);
262 DECLARE_HANDLE(HACMSTREAM
);
263 DECLARE_HANDLE(HMETAFILEPICT
);
265 DECLARE_HANDLE(HACCEL
);
266 DECLARE_HANDLE(HBITMAP
);
267 DECLARE_HANDLE(HBRUSH
);
268 DECLARE_HANDLE(HCOLORSPACE
);
269 DECLARE_HANDLE(HCURSOR
);
271 DECLARE_HANDLE(HDROP
);
272 DECLARE_HANDLE(HDRVR
);
273 DECLARE_HANDLE(HDWP
);
274 DECLARE_HANDLE(HENHMETAFILE
);
276 DECLARE_HANDLE(HFONT
);
277 DECLARE_HANDLE(HICON
);
278 DECLARE_HANDLE(HINSTANCE
);
279 DECLARE_HANDLE(HKEY
);
280 DECLARE_HANDLE(HMENU
);
281 DECLARE_HANDLE(HMETAFILE
);
282 DECLARE_HANDLE(HMIDI
);
283 DECLARE_HANDLE(HMIDIIN
);
284 DECLARE_HANDLE(HMIDIOUT
);
285 DECLARE_HANDLE(HMIDISTRM
);
286 DECLARE_HANDLE(HMIXER
);
287 DECLARE_HANDLE(HMIXEROBJ
);
288 DECLARE_HANDLE(HMMIO
);
289 DECLARE_HANDLE(HPALETTE
);
290 DECLARE_HANDLE(HPEN
);
291 DECLARE_HANDLE(HQUEUE
);
292 DECLARE_HANDLE(HRGN
);
293 DECLARE_HANDLE(HRSRC
);
294 DECLARE_HANDLE(HTASK
);
295 DECLARE_HANDLE(HWAVE
);
296 DECLARE_HANDLE(HWAVEIN
);
297 DECLARE_HANDLE(HWAVEOUT
);
298 DECLARE_HANDLE(HWINSTA
);
299 DECLARE_HANDLE(HDESK
);
300 DECLARE_HANDLE(HWND
);
302 DECLARE_HANDLE(HRASCONN
);
304 /* Handle types that must remain interchangeable even with strict on */
306 typedef HINSTANCE HMODULE
;
307 typedef HANDLE HGDIOBJ
;
308 typedef HANDLE HGLOBAL
;
309 typedef HANDLE HLOCAL
;
310 typedef HANDLE GLOBALHANDLE
;
311 typedef HANDLE LOCALHANDLE
;
313 /* Callback function pointers types */
315 typedef BOOL
CALLBACK (*DATEFMT_ENUMPROCA
)(LPSTR
);
316 typedef BOOL
CALLBACK (*DATEFMT_ENUMPROCW
)(LPWSTR
);
317 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC
)
318 typedef BOOL
CALLBACK (*DLGPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
319 typedef LRESULT
CALLBACK (*DRIVERPROC
)(DWORD
,HDRVR
,UINT
,LPARAM
,LPARAM
);
320 typedef INT
CALLBACK (*EDITWORDBREAKPROCA
)(LPSTR
,INT
,INT
,INT
);
321 typedef INT
CALLBACK (*EDITWORDBREAKPROCW
)(LPWSTR
,INT
,INT
,INT
);
322 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC
)
323 typedef LRESULT
CALLBACK (*FARPROC
)();
324 typedef INT
CALLBACK (*PROC
)();
325 typedef BOOL
CALLBACK (*GRAYSTRINGPROC
)(HDC
,LPARAM
,INT
);
326 typedef LRESULT
CALLBACK (*HOOKPROC
)(INT
,WPARAM
,LPARAM
);
327 typedef BOOL
CALLBACK (*PROPENUMPROCA
)(HWND
,LPCSTR
,HANDLE
);
328 typedef BOOL
CALLBACK (*PROPENUMPROCW
)(HWND
,LPCWSTR
,HANDLE
);
329 DECL_WINELIB_TYPE_AW(PROPENUMPROC
)
330 typedef BOOL
CALLBACK (*PROPENUMPROCEXA
)(HWND
,LPCSTR
,HANDLE
,LPARAM
);
331 typedef BOOL
CALLBACK (*PROPENUMPROCEXW
)(HWND
,LPCWSTR
,HANDLE
,LPARAM
);
332 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX
)
333 typedef BOOL
CALLBACK (*TIMEFMT_ENUMPROCA
)(LPSTR
);
334 typedef BOOL
CALLBACK (*TIMEFMT_ENUMPROCW
)(LPWSTR
);
335 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC
)
336 typedef VOID
CALLBACK (*TIMERPROC
)(HWND
,UINT
,UINT
,DWORD
);
337 typedef BOOL
CALLBACK (*WNDENUMPROC
)(HWND
,LPARAM
);
338 typedef LRESULT
CALLBACK (*WNDPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
340 /* Define some empty macros for compatibility with Windows code. */
352 #endif /* __WINE__ */
356 /* Macro for structure packing. */
359 #define WINE_PACKED __attribute__((packed))
360 #define WINE_UNUSED __attribute__((unused))
361 #define WINE_NORETURN __attribute__((noreturn))
363 #define WINE_PACKED /* nothing */
364 #define WINE_UNUSED /* nothing */
365 #define WINE_NORETURN /* nothing */
368 /* Macros to split words and longs. */
370 #define LOBYTE(w) ((BYTE)(WORD)(w))
371 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
373 #define LOWORD(l) ((WORD)(DWORD)(l))
374 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
376 #define SLOWORD(l) ((SHORT)(LONG)(l))
377 #define SHIWORD(l) ((SHORT)((LONG)(l) >> 16))
379 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
380 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
381 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
382 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
383 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
384 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
386 #define SELECTOROF(ptr) (HIWORD(ptr))
387 #define OFFSETOF(ptr) (LOWORD(ptr))
390 /* macros to set parts of a DWORD (not in the Windows API) */
391 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
392 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
393 #define SET_HIBYTE(dw,val) ((dw) = ((dw) & 0xffff00ff) | (LOBYTE(val) << 8))
394 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
397 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
398 /* Note: These macros are semantically broken, at least for wrc. wrc
399 spits out data in the platform's current binary format, *not* in
400 little-endian format. These macros are used throughout the resource
401 code to load and store data to the resources. Since it is unlikely
402 that we'll ever be dealing with little-endian resource data, the
403 byte-swapping nature of these macros has been disabled. Rather than
404 remove the use of these macros from the resource loading code, the
405 macros have simply been disabled. In the future, someone may want
406 to reactivate these macros for other purposes. In that case, the
407 resource code will have to be modified to use different macros. */
410 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
411 #define GET_WORD(ptr) (*(WORD *)(ptr))
412 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
413 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
415 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
416 *((BYTE *)(ptr) + 1) = HIBYTE(w))
417 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
418 (WORD)(*((BYTE *)(ptr)+1) << 8)))
419 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
420 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
421 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
422 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
425 /* min and max macros */
426 #define __max(a,b) (((a) > (b)) ? (a) : (b))
427 #define __min(a,b) (((a) < (b)) ? (a) : (b))
429 #define max(a,b) (((a) > (b)) ? (a) : (b))
432 #define min(a,b) (((a) < (b)) ? (a) : (b))
435 #define _MAX_PATH 260
439 #define _MAX_FNAME 255
442 #define HFILE_ERROR ((HFILE)-1)
444 /* The SIZE structure */
445 typedef struct tagSIZE
449 } SIZE
, *PSIZE
, *LPSIZE
;
451 typedef SIZE SIZEL
, *PSIZEL
, *LPSIZEL
;
453 /* The POINT structure */
454 typedef struct tagPOINT
458 } POINT
, *PPOINT
, *LPPOINT
;
460 typedef struct _POINTL
466 /* The POINTS structure */
468 typedef struct tagPOINTS
472 } POINTS
, *PPOINTS
, *LPPOINTS
;
474 /* The RECT structure */
475 typedef struct tagRECT
481 } RECT
, *PRECT
, *LPRECT
;
482 typedef const RECT
*LPCRECT
;
485 typedef struct tagRECTL
491 } RECTL
, *PRECTL
, *LPRECTL
;
493 typedef const RECTL
*LPCRECTL
;
499 #endif /* __WINE_WINDEF_H */