Changed the macros in the msvcrt headers to static inline functions.
[wine] / include / windef.h
1 /*
2  * Basic types definitions
3  *
4  * Copyright 1996 Alexandre Julliard
5  *
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.
10  *
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.
15  *
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #ifndef __WINE_WINDEF_H
22 #define __WINE_WINDEF_H
23
24 #ifdef __WINESRC__
25 # undef UNICODE
26 #endif  /* __WINESRC__ */
27
28 #ifndef WINVER
29 #define WINVER 0x0500
30 #endif
31
32 #ifndef NO_STRICT
33 # ifndef STRICT
34 #  define STRICT
35 # endif /* STRICT */
36 #endif /* NO_STRICT */
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 /* Calling conventions definitions */
43
44 #if defined(__i386__) && !defined(_X86_)
45 # define _X86_
46 #endif
47
48 #ifndef __stdcall
49 # ifdef __i386__
50 #  ifdef __GNUC__
51 #   define __stdcall __attribute__((__stdcall__))
52 #  elif defined(_MSC_VER)
53     /* Nothing needs to be done. __stdcall already exists */
54 #  else
55 #   error You need to define __stdcall for your compiler
56 #  endif
57 # else  /* __i386__ */
58 #  define __stdcall
59 # endif  /* __i386__ */
60 #endif /* __stdcall */
61
62 #ifndef __cdecl
63 # if defined(__i386__) && defined(__GNUC__)
64 #  define __cdecl __attribute__((__cdecl__))
65 # elif !defined(_MSC_VER)
66 #  define __cdecl
67 # endif
68 #endif /* __stdcall */
69
70 #ifndef __WINESRC__
71
72 #ifndef pascal
73 #define pascal      __stdcall
74 #endif
75 #ifndef _pascal
76 #define _pascal     __stdcall
77 #endif
78 #ifndef _stdcall
79 #define _stdcall    __stdcall
80 #endif
81 #ifndef _fastcall
82 #define _fastcall   __stdcall
83 #endif
84 #ifndef __fastcall
85 #define __fastcall  __stdcall
86 #endif
87 #ifndef __export
88 #define __export    __stdcall
89 #endif
90 #ifndef cdecl
91 #define cdecl       __cdecl
92 #endif
93 #ifndef _cdecl
94 #define _cdecl      __cdecl
95 #endif
96
97 #ifndef near
98 #define near
99 #endif
100 #ifndef far
101 #define far
102 #endif
103 #ifndef _near
104 #define _near
105 #endif
106 #ifndef _far
107 #define _far
108 #endif
109 #ifndef NEAR
110 #define NEAR
111 #endif
112 #ifndef FAR
113 #define FAR
114 #endif
115
116 #ifndef _declspec
117 #define _declspec(x)
118 #endif
119 #ifndef __declspec
120 #define __declspec(x)
121 #endif
122
123 #endif /* __WINESRC__ */
124
125 #define CALLBACK    __stdcall
126 #define WINAPI      __stdcall
127 #define APIPRIVATE  __stdcall
128 #define PASCAL      __stdcall
129 #define CDECL       __cdecl
130 #define _CDECL      __cdecl
131 #define WINAPIV     __cdecl
132 #define APIENTRY    WINAPI
133 #define CONST       const
134
135 /* Misc. constants. */
136
137 #undef NULL
138 #ifdef __cplusplus
139 #define NULL  0
140 #else
141 #define NULL  ((void*)0)
142 #endif
143
144 #ifdef FALSE
145 #undef FALSE
146 #endif
147 #define FALSE 0
148
149 #ifdef TRUE
150 #undef TRUE
151 #endif
152 #define TRUE  1
153
154 #ifndef IN
155 #define IN
156 #endif
157
158 #ifndef OUT
159 #define OUT
160 #endif
161
162 #ifndef OPTIONAL
163 #define OPTIONAL
164 #endif
165
166 /* Standard data types */
167
168 typedef void                                   *LPVOID;
169 typedef const void                             *LPCVOID;
170 typedef int             BOOL,       *PBOOL,    *LPBOOL;
171 typedef unsigned char   BYTE,       *PBYTE,    *LPBYTE;
172 typedef unsigned char   UCHAR,      *PUCHAR;
173 typedef unsigned short  WORD,       *PWORD,    *LPWORD;
174 typedef unsigned short  USHORT,     *PUSHORT;
175 typedef int             INT,        *PINT,     *LPINT;
176 typedef unsigned int    UINT,       *PUINT;
177 typedef long                                   *LPLONG;
178 typedef unsigned long   DWORD,      *PDWORD,   *LPDWORD;
179 typedef unsigned long   ULONG,      *PULONG;
180 typedef float           FLOAT,      *PFLOAT;
181 typedef double          DOUBLE;
182 typedef double          DATE;
183
184 #include "winnt.h"
185
186 /* Macros to map Winelib names to the correct implementation name */
187 /* depending on __WINESRC__ and UNICODE macros.                   */
188 /* Note that Winelib is purely Win32.                             */
189
190 #ifdef __WINESRC__
191 # define WINELIB_NAME_AW(func) \
192     func##_must_be_suffixed_with_W_or_A_in_this_context \
193     func##_must_be_suffixed_with_W_or_A_in_this_context
194 #else  /* __WINESRC__ */
195 # ifdef UNICODE
196 #  define WINELIB_NAME_AW(func) func##W
197 # else
198 #  define WINELIB_NAME_AW(func) func##A
199 # endif  /* UNICODE */
200 #endif  /* __WINESRC__ */
201
202 #ifdef __WINESRC__
203 # define DECL_WINELIB_TYPE_AW(type)  /* nothing */
204 #else   /* __WINESRC__ */
205 # define DECL_WINELIB_TYPE_AW(type)  typedef WINELIB_NAME_AW(type) type;
206 #endif  /* __WINESRC__ */
207
208
209 /* Polymorphic types */
210
211 typedef UINT_PTR        WPARAM;
212 typedef LONG_PTR        LPARAM;
213 typedef LONG_PTR        LRESULT;
214
215 /* Integer types */
216
217 typedef WORD            ATOM;
218 typedef WORD            CATCHBUF[9];
219 typedef WORD           *LPCATCHBUF;
220 typedef DWORD           COLORREF, *LPCOLORREF;
221
222
223 /* Handle types */
224
225 typedef int HFILE;
226 DECLARE_HANDLE(HACCEL);
227 DECLARE_HANDLE(HBITMAP);
228 DECLARE_HANDLE(HBRUSH);
229 DECLARE_HANDLE(HCOLORSPACE);
230 DECLARE_HANDLE(HDC);
231 DECLARE_HANDLE(HDESK);
232 DECLARE_HANDLE(HENHMETAFILE);
233 DECLARE_HANDLE(HFONT);
234 DECLARE_HANDLE(HHOOK);
235 DECLARE_HANDLE(HICON);
236 DECLARE_HANDLE(HINSTANCE);
237 DECLARE_HANDLE(HKEY);
238 typedef HKEY *PHKEY;
239 DECLARE_HANDLE(HKL);
240 DECLARE_HANDLE(HMENU);
241 DECLARE_HANDLE(HMETAFILE);
242 DECLARE_HANDLE(HMONITOR);
243 DECLARE_HANDLE(HPALETTE);
244 DECLARE_HANDLE(HPEN);
245 DECLARE_HANDLE(HRGN);
246 DECLARE_HANDLE(HRSRC);
247 DECLARE_HANDLE(HTASK);
248 DECLARE_HANDLE(HWINEVENTHOOK);
249 DECLARE_HANDLE(HWINSTA);
250 DECLARE_HANDLE(HWND);
251
252 /* Handle types that must remain interchangeable even with strict on */
253
254 typedef HINSTANCE HMODULE;
255 typedef HANDLE HGDIOBJ;
256 typedef HANDLE HGLOBAL;
257 typedef HANDLE HLOCAL;
258 typedef HANDLE GLOBALHANDLE;
259 typedef HANDLE LOCALHANDLE;
260 typedef HICON HCURSOR;
261
262 /* Callback function pointers types */
263
264 typedef INT     (CALLBACK *FARPROC)();
265 typedef INT     (CALLBACK *PROC)();
266
267
268 /* Macros to split words and longs. */
269
270 #define LOBYTE(w)              ((BYTE)(WORD)(w))
271 #define HIBYTE(w)              ((BYTE)((WORD)(w) >> 8))
272
273 #define LOWORD(l)              ((WORD)(DWORD)(l))
274 #define HIWORD(l)              ((WORD)((DWORD)(l) >> 16))
275
276 #define SLOWORD(l)             ((SHORT)(LONG)(l))
277 #define SHIWORD(l)             ((SHORT)((LONG)(l) >> 16))
278
279 #define MAKEWORD(low,high)     ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
280 #define MAKELONG(low,high)     ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
281 #define MAKELPARAM(low,high)   ((LPARAM)MAKELONG(low,high))
282 #define MAKEWPARAM(low,high)   ((WPARAM)MAKELONG(low,high))
283 #define MAKELRESULT(low,high)  ((LRESULT)MAKELONG(low,high))
284
285 #define SELECTOROF(ptr)     (HIWORD(ptr))
286 #define OFFSETOF(ptr)       (LOWORD(ptr))
287
288 /* min and max macros */
289 #ifndef NOMINMAX
290 #ifndef max
291 #define max(a,b)   (((a) > (b)) ? (a) : (b))
292 #endif
293 #ifndef min
294 #define min(a,b)   (((a) < (b)) ? (a) : (b))
295 #endif
296 #endif  /* NOMINMAX */
297
298 #ifdef MAX_PATH /* Work-around for Mingw */ 
299 #undef MAX_PATH
300 #endif /* MAX_PATH */
301
302 #define MAX_PATH        260
303 #define HFILE_ERROR     ((HFILE)-1)
304
305 /* The SIZE structure */
306 typedef struct tagSIZE
307 {
308     LONG cx;
309     LONG cy;
310 } SIZE, *PSIZE, *LPSIZE;
311
312 typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;
313
314 /* The POINT structure */
315 typedef struct tagPOINT
316 {
317     LONG  x;
318     LONG  y;
319 } POINT, *PPOINT, *LPPOINT;
320
321 typedef struct _POINTL
322 {
323     LONG x;
324     LONG y;
325 } POINTL;
326
327 /* The POINTS structure */
328
329 typedef struct tagPOINTS
330 {
331     SHORT x;
332     SHORT y;
333 } POINTS, *PPOINTS, *LPPOINTS;
334
335 /* The RECT structure */
336 typedef struct tagRECT
337 {
338     LONG left;
339     LONG top;
340     LONG right;
341     LONG bottom;
342 } RECT, *PRECT, *LPRECT;
343 typedef const RECT *LPCRECT;
344
345 typedef struct tagRECTL
346 {
347     LONG left;
348     LONG top;
349     LONG right;
350     LONG bottom;
351 } RECTL, *PRECTL, *LPRECTL;
352
353 typedef const RECTL *LPCRECTL;
354
355 #ifdef __cplusplus
356 }
357 #endif
358
359 #endif /* __WINE_WINDEF_H */