Added pow() forward.
[wine.git] / include / windef.h
bloba39fd33caca60d1b5c135c447c5204b1e60a570e
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 # undef UNICODE
12 #endif /* __WINE__ */
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
18 /* Misc. constants. */
20 #define WINVER 0x0500
22 #ifdef FALSE
23 #undef FALSE
24 #endif
25 #define FALSE 0
27 #ifdef TRUE
28 #undef TRUE
29 #endif
30 #define TRUE 1
32 #ifdef NULL
33 #undef NULL
34 #endif
35 #define NULL 0
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. */
41 #ifdef __WINE__
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
45 #else /* __WINE__ */
46 # ifdef UNICODE
47 # define WINELIB_NAME_AW(func) func##W
48 # else
49 # define WINELIB_NAME_AW(func) func##A
50 # endif /* UNICODE */
51 #endif /* __WINE__ */
53 #ifdef __WINE__
54 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
55 #else /* __WINE__ */
56 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
57 #endif /* __WINE__ */
59 #ifdef __WINE__
60 # define NONAMELESSSTRUCT
61 # define NONAMELESSUNION
62 #else
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
66 # endif
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
70 # endif
71 #endif
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 */
113 #ifdef __i386__
114 # ifndef _X86_
115 # define _X86_
116 # endif
117 # if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
118 # define __stdcall __attribute__((__stdcall__))
119 # define __cdecl __attribute__((__cdecl__))
120 # else
121 # error You need gcc >= 2.7 to build Wine on a 386
122 # endif /* __GNUC__ */
123 #else /* __i386__ */
124 # define __stdcall
125 # define __cdecl
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
145 #ifndef _declspec
146 #define _declspec(x)
147 #endif
148 #ifndef __declspec
149 #define __declspec(x)
150 #endif
152 #define CONST const
154 /* Standard data types. These are the same for emulator and library. */
156 typedef void VOID;
157 typedef int INT;
158 typedef unsigned int UINT;
159 typedef unsigned short WORD;
160 typedef unsigned long DWORD;
161 typedef unsigned long ULONG;
162 typedef unsigned char BYTE;
163 typedef long LONG;
164 typedef short SHORT;
165 typedef unsigned short USHORT;
166 typedef char CHAR;
167 typedef unsigned char UCHAR;
168 /* Some systems might have wchar_t, but we really need 16 bit characters */
169 typedef unsigned short WCHAR;
170 typedef int BOOL;
171 typedef double DATE;
172 typedef double DOUBLE;
174 /* FIXME: Wine does not compile with strict on, therefore strict
175 * handles are presently only usable on machines where sizeof(UINT) ==
176 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
177 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
178 * they exist as UINTs but to the Winelib user who turns on strict,
179 * they exist as void*. If there is a size difference between UINT and
180 * void* then things get ugly. */
181 #ifdef STRICT
182 typedef VOID* HANDLE;
183 #else
184 typedef UINT HANDLE;
185 #endif
188 typedef HANDLE *LPHANDLE;
190 /* Integer types. These are the same for emulator and library. */
191 typedef UINT WPARAM;
192 typedef LONG LPARAM;
193 typedef LONG HRESULT;
194 typedef LONG LRESULT;
195 typedef WORD ATOM;
196 typedef WORD CATCHBUF[9];
197 typedef WORD *LPCATCHBUF;
198 typedef HANDLE HHOOK;
199 typedef HANDLE HMONITOR;
200 typedef DWORD LCID;
201 typedef WORD LANGID;
202 typedef float FLOAT;
204 /* Pointers types. These are the same for emulator and library. */
205 /* winnt types */
206 typedef VOID *PVOID;
207 typedef const void *PCVOID;
208 typedef CHAR *PCHAR;
209 typedef UCHAR *PUCHAR;
210 typedef BYTE *PBYTE;
211 typedef WORD *PWORD;
212 typedef USHORT *PUSHORT;
213 typedef SHORT *PSHORT;
214 typedef ULONG *PULONG;
215 typedef LONG *PLONG;
216 typedef DWORD *PDWORD;
217 /* common win32 types */
218 typedef CHAR *LPSTR;
219 typedef CHAR *PSTR;
220 typedef const CHAR *LPCSTR;
221 typedef const CHAR *PCSTR;
222 typedef WCHAR *LPWSTR;
223 typedef WCHAR *PWSTR;
224 typedef const WCHAR *LPCWSTR;
225 typedef const WCHAR *PCWSTR;
226 typedef BYTE *LPBYTE;
227 typedef WORD *LPWORD;
228 typedef DWORD *LPDWORD;
229 typedef LONG *LPLONG;
230 typedef VOID *LPVOID;
231 typedef const VOID *LPCVOID;
232 typedef INT *PINT;
233 typedef INT *LPINT;
234 typedef UINT *PUINT;
235 typedef UINT *LPUINT;
236 typedef FLOAT *PFLOAT;
237 typedef FLOAT *LPFLOAT;
238 typedef BOOL *PBOOL;
239 typedef BOOL *LPBOOL;
241 /* Handle types that exist both in Win16 and Win32. */
243 #ifdef STRICT
244 #define DECLARE_HANDLE(a) \
245 typedef struct a##__ { int unused; } *a; \
246 typedef a *P##a; \
247 typedef a *LP##a
248 #else /*STRICT*/
249 #define DECLARE_HANDLE(a) \
250 typedef HANDLE a; \
251 typedef a *P##a; \
252 typedef a *LP##a
253 #endif /*STRICT*/
255 DECLARE_HANDLE(HACMDRIVERID);
256 DECLARE_HANDLE(HACMDRIVER);
257 DECLARE_HANDLE(HACMOBJ);
258 DECLARE_HANDLE(HACMSTREAM);
259 DECLARE_HANDLE(HMETAFILEPICT);
261 DECLARE_HANDLE(HACCEL);
262 DECLARE_HANDLE(HBITMAP);
263 DECLARE_HANDLE(HBRUSH);
264 DECLARE_HANDLE(HCOLORSPACE);
265 DECLARE_HANDLE(HDC);
266 DECLARE_HANDLE(HDROP);
267 DECLARE_HANDLE(HDRVR);
268 DECLARE_HANDLE(HDWP);
269 DECLARE_HANDLE(HENHMETAFILE);
270 typedef int HFILE;
271 DECLARE_HANDLE(HFONT);
272 DECLARE_HANDLE(HICON);
273 DECLARE_HANDLE(HINSTANCE);
274 DECLARE_HANDLE(HKEY);
275 DECLARE_HANDLE(HMENU);
276 DECLARE_HANDLE(HMETAFILE);
277 DECLARE_HANDLE(HMIDI);
278 DECLARE_HANDLE(HMIDIIN);
279 DECLARE_HANDLE(HMIDIOUT);
280 DECLARE_HANDLE(HMIDISTRM);
281 DECLARE_HANDLE(HMIXER);
282 DECLARE_HANDLE(HMIXEROBJ);
283 DECLARE_HANDLE(HMMIO);
284 DECLARE_HANDLE(HPALETTE);
285 DECLARE_HANDLE(HPEN);
286 DECLARE_HANDLE(HQUEUE);
287 DECLARE_HANDLE(HRGN);
288 DECLARE_HANDLE(HRSRC);
289 DECLARE_HANDLE(HTASK);
290 DECLARE_HANDLE(HWAVE);
291 DECLARE_HANDLE(HWAVEIN);
292 DECLARE_HANDLE(HWAVEOUT);
293 DECLARE_HANDLE(HWINSTA);
294 DECLARE_HANDLE(HDESK);
295 DECLARE_HANDLE(HWND);
296 DECLARE_HANDLE(HKL);
297 DECLARE_HANDLE(HRASCONN);
299 /* Handle types that must remain interchangeable even with strict on */
301 typedef HINSTANCE HMODULE;
302 typedef HANDLE HGDIOBJ;
303 typedef HANDLE HGLOBAL;
304 typedef HANDLE HLOCAL;
305 typedef HANDLE GLOBALHANDLE;
306 typedef HANDLE LOCALHANDLE;
307 typedef HICON HCURSOR;
309 /* Callback function pointers types */
311 typedef BOOL CALLBACK (*DATEFMT_ENUMPROCA)(LPSTR);
312 typedef BOOL CALLBACK (*DATEFMT_ENUMPROCW)(LPWSTR);
313 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC)
314 typedef BOOL CALLBACK (*DLGPROC)(HWND,UINT,WPARAM,LPARAM);
315 typedef LRESULT CALLBACK (*DRIVERPROC)(DWORD,HDRVR,UINT,LPARAM,LPARAM);
316 typedef INT CALLBACK (*EDITWORDBREAKPROCA)(LPSTR,INT,INT,INT);
317 typedef INT CALLBACK (*EDITWORDBREAKPROCW)(LPWSTR,INT,INT,INT);
318 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC)
319 typedef LRESULT CALLBACK (*FARPROC)();
320 typedef INT CALLBACK (*PROC)();
321 typedef BOOL CALLBACK (*GRAYSTRINGPROC)(HDC,LPARAM,INT);
322 typedef LRESULT CALLBACK (*HOOKPROC)(INT,WPARAM,LPARAM);
323 typedef BOOL CALLBACK (*PROPENUMPROCA)(HWND,LPCSTR,HANDLE);
324 typedef BOOL CALLBACK (*PROPENUMPROCW)(HWND,LPCWSTR,HANDLE);
325 DECL_WINELIB_TYPE_AW(PROPENUMPROC)
326 typedef BOOL CALLBACK (*PROPENUMPROCEXA)(HWND,LPCSTR,HANDLE,LPARAM);
327 typedef BOOL CALLBACK (*PROPENUMPROCEXW)(HWND,LPCWSTR,HANDLE,LPARAM);
328 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX)
329 typedef BOOL CALLBACK (*TIMEFMT_ENUMPROCA)(LPSTR);
330 typedef BOOL CALLBACK (*TIMEFMT_ENUMPROCW)(LPWSTR);
331 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC)
332 typedef VOID CALLBACK (*TIMERPROC)(HWND,UINT,UINT,DWORD);
333 typedef BOOL CALLBACK (*WNDENUMPROC)(HWND,LPARAM);
334 typedef LRESULT CALLBACK (*WNDPROC)(HWND,UINT,WPARAM,LPARAM);
336 /* Define some empty macros for compatibility with Windows code. */
338 #ifndef __WINE__
339 #define NEAR
340 #define FAR
341 #define near
342 #define far
343 #define _near
344 #define _far
345 #define IN
346 #define OUT
347 #define OPTIONAL
348 #endif /* __WINE__ */
350 #include "winnt.h"
352 /* Macro for structure packing. */
354 #ifdef __GNUC__
355 #define WINE_PACKED __attribute__((packed))
356 #define WINE_UNUSED __attribute__((unused))
357 #define WINE_NORETURN __attribute__((noreturn))
358 #else
359 #define WINE_PACKED /* nothing */
360 #define WINE_UNUSED /* nothing */
361 #define WINE_NORETURN /* nothing */
362 #endif
364 /* Macros to split words and longs. */
366 #define LOBYTE(w) ((BYTE)(WORD)(w))
367 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
369 #define LOWORD(l) ((WORD)(DWORD)(l))
370 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
372 #define SLOWORD(l) ((SHORT)(LONG)(l))
373 #define SHIWORD(l) ((SHORT)((LONG)(l) >> 16))
375 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
376 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
377 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
378 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
379 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
380 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
382 #define SELECTOROF(ptr) (HIWORD(ptr))
383 #define OFFSETOF(ptr) (LOWORD(ptr))
385 #ifdef __WINE__
386 /* macros to set parts of a DWORD (not in the Windows API) */
387 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
388 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
389 #define SET_HIBYTE(dw,val) ((dw) = ((dw) & 0xffff00ff) | (LOBYTE(val) << 8))
390 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
391 #endif
393 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
394 /* Note: These macros are semantically broken, at least for wrc. wrc
395 spits out data in the platform's current binary format, *not* in
396 little-endian format. These macros are used throughout the resource
397 code to load and store data to the resources. Since it is unlikely
398 that we'll ever be dealing with little-endian resource data, the
399 byte-swapping nature of these macros has been disabled. Rather than
400 remove the use of these macros from the resource loading code, the
401 macros have simply been disabled. In the future, someone may want
402 to reactivate these macros for other purposes. In that case, the
403 resource code will have to be modified to use different macros. */
405 #if 1
406 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
407 #define GET_WORD(ptr) (*(WORD *)(ptr))
408 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
409 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
410 #else
411 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
412 *((BYTE *)(ptr) + 1) = HIBYTE(w))
413 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
414 (WORD)(*((BYTE *)(ptr)+1) << 8)))
415 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
416 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
417 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
418 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
419 #endif /* 1 */
421 /* min and max macros */
422 #define __max(a,b) (((a) > (b)) ? (a) : (b))
423 #define __min(a,b) (((a) < (b)) ? (a) : (b))
424 #ifndef max
425 #define max(a,b) (((a) > (b)) ? (a) : (b))
426 #endif
427 #ifndef min
428 #define min(a,b) (((a) < (b)) ? (a) : (b))
429 #endif
431 #define _MAX_PATH 260
432 #define MAX_PATH 260
433 #define _MAX_DRIVE 3
434 #define _MAX_DIR 256
435 #define _MAX_FNAME 255
436 #define _MAX_EXT 256
438 #define HFILE_ERROR ((HFILE)-1)
440 /* The SIZE structure */
441 typedef struct tagSIZE
443 LONG cx;
444 LONG cy;
445 } SIZE, *PSIZE, *LPSIZE;
447 typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;
449 /* The POINT structure */
450 typedef struct tagPOINT
452 LONG x;
453 LONG y;
454 } POINT, *PPOINT, *LPPOINT;
456 typedef struct _POINTL
458 LONG x;
459 LONG y;
460 } POINTL;
462 /* The POINTS structure */
464 typedef struct tagPOINTS
466 SHORT x;
467 SHORT y;
468 } POINTS, *PPOINTS, *LPPOINTS;
470 /* The RECT structure */
471 typedef struct tagRECT
473 INT left;
474 INT top;
475 INT right;
476 INT bottom;
477 } RECT, *PRECT, *LPRECT;
478 typedef const RECT *LPCRECT;
481 typedef struct tagRECTL
483 LONG left;
484 LONG top;
485 LONG right;
486 LONG bottom;
487 } RECTL, *PRECTL, *LPRECTL;
489 typedef const RECTL *LPCRECTL;
491 #ifdef __cplusplus
493 #endif
495 #endif /* __WINE_WINDEF_H */