windef.h 8.88 KB
Newer Older
1 2 3 4
/*
 * Basic types definitions
 *
 * Copyright 1996 Alexandre Julliard
5 6 7 8 9 10 11 12 13 14 15 16 17
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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
19
 */
20

21 22
#ifndef _WINDEF_
#define _WINDEF_
23

24
#ifndef WINVER
25
#define WINVER 0x0500
26
#endif
27

28 29 30 31 32 33
#ifndef NO_STRICT
# ifndef STRICT
#  define STRICT
# endif /* STRICT */
#endif /* NO_STRICT */

34 35 36 37 38 39
#ifdef __cplusplus
extern "C" {
#endif

/* Calling conventions definitions */

40 41 42 43
#if defined(__i386__) && !defined(_X86_)
# define _X86_
#endif

44 45 46 47
#if defined(_X86_) && !defined(__i386__)
# define __i386__
#endif

48
#if defined(__x86_64__) && !defined(_WIN64)
49 50 51
#define _WIN64
#endif

52 53 54
#ifndef __stdcall
# ifdef __i386__
#  ifdef __GNUC__
55
#   ifdef __APPLE__ /* Mac OS X uses a 16-byte aligned stack and not a 4-byte one */
56 57 58 59
#    define __stdcall __attribute__((__stdcall__)) __attribute__((__force_align_arg_pointer__))
#   else
#    define __stdcall __attribute__((__stdcall__))
#   endif
60 61 62 63 64 65 66 67 68 69 70 71
#  elif defined(_MSC_VER)
    /* Nothing needs to be done. __stdcall already exists */
#  else
#   error You need to define __stdcall for your compiler
#  endif
# else  /* __i386__ */
#  define __stdcall
# endif  /* __i386__ */
#endif /* __stdcall */

#ifndef __cdecl
# if defined(__i386__) && defined(__GNUC__)
72
#  ifdef __APPLE__ /* Mac OS X uses 16-byte aligned stack and not a 4-byte one */
73 74 75 76
#   define __cdecl __attribute__((__cdecl__)) __attribute__((__force_align_arg_pointer__))
#  else
#   define __cdecl __attribute__((__cdecl__))
#  endif
77 78
# elif !defined(_MSC_VER)
#  define __cdecl
79
# endif
80
#endif /* __cdecl */
81

82 83 84 85 86
#ifdef __WINESRC__
#define __ONLY_IN_WINELIB(x)	do_not_use_this_in_wine
#else
#define __ONLY_IN_WINELIB(x)	x
#endif
87 88

#ifndef pascal
89
#define pascal      __ONLY_IN_WINELIB(__stdcall)
90 91
#endif
#ifndef _pascal
92
#define _pascal	    __ONLY_IN_WINELIB(__stdcall)
93 94
#endif
#ifndef _stdcall
95
#define _stdcall    __ONLY_IN_WINELIB(__stdcall)
96 97
#endif
#ifndef _fastcall
98
#define _fastcall   __ONLY_IN_WINELIB(__stdcall)
99 100
#endif
#ifndef __fastcall
101
#define __fastcall  __ONLY_IN_WINELIB(__stdcall)
102 103
#endif
#ifndef __export
104
#define __export    __ONLY_IN_WINELIB(__stdcall)
105 106
#endif
#ifndef cdecl
107
#define cdecl       __ONLY_IN_WINELIB(__cdecl)
108 109
#endif
#ifndef _cdecl
110
#define _cdecl      __ONLY_IN_WINELIB(__cdecl)
111 112 113
#endif

#ifndef near
114
#define near        __ONLY_IN_WINELIB(/* nothing */)
115 116
#endif
#ifndef far
117
#define far         __ONLY_IN_WINELIB(/* nothing */)
118 119
#endif
#ifndef _near
120
#define _near       __ONLY_IN_WINELIB(/* nothing */)
121 122
#endif
#ifndef _far
123
#define _far        __ONLY_IN_WINELIB(/* nothing */)
124 125
#endif
#ifndef NEAR
126
#define NEAR        __ONLY_IN_WINELIB(/* nothing */)
127 128
#endif
#ifndef FAR
129
#define FAR         __ONLY_IN_WINELIB(/* nothing */)
130 131
#endif

132 133
#ifndef _MSC_VER
# ifndef _declspec
134
#  define _declspec(x)    __ONLY_IN_WINELIB(/* nothing */)
135 136
# endif
# ifndef __declspec
137
#  define __declspec(x)   __ONLY_IN_WINELIB(/* nothing */)
138
# endif
139 140
#endif

141 142 143 144
#ifdef _MSC_VER
# define inline __inline
#endif

145 146 147 148 149 150 151 152 153
#define CALLBACK    __stdcall
#define WINAPI      __stdcall
#define APIPRIVATE  __stdcall
#define PASCAL      __stdcall
#define CDECL       __cdecl
#define _CDECL      __cdecl
#define WINAPIV     __cdecl
#define APIENTRY    WINAPI
#define CONST       const
154

155
/* Misc. constants. */
156

157
#undef NULL
158
#ifdef __cplusplus
159 160 161 162 163 164 165
#define NULL  0
#else
#define NULL  ((void*)0)
#endif

#ifdef FALSE
#undef FALSE
166
#endif
167
#define FALSE 0
168

169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
#ifdef TRUE
#undef TRUE
#endif
#define TRUE  1

#ifndef IN
#define IN
#endif

#ifndef OUT
#define OUT
#endif

#ifndef OPTIONAL
#define OPTIONAL
#endif

/* Standard data types */

typedef void                                   *LPVOID;
typedef const void                             *LPCVOID;
typedef int             BOOL,       *PBOOL,    *LPBOOL;
typedef unsigned char   BYTE,       *PBYTE,    *LPBYTE;
typedef unsigned char   UCHAR,      *PUCHAR;
typedef unsigned short  WORD,       *PWORD,    *LPWORD;
typedef unsigned short  USHORT,     *PUSHORT;
typedef int             INT,        *PINT,     *LPINT;
typedef unsigned int    UINT,       *PUINT;
197 198
typedef float           FLOAT,      *PFLOAT;
typedef char                        *PSZ;
199
#ifdef _MSC_VER
200 201 202
typedef long                                   *LPLONG;
typedef unsigned long   DWORD,      *PDWORD,   *LPDWORD;
typedef unsigned long   ULONG,      *PULONG;
203 204 205 206
#else
typedef int                                    *LPLONG;
typedef unsigned int    DWORD,      *PDWORD,   *LPDWORD;
typedef unsigned int    ULONG,      *PULONG;
207
#endif
208

209 210 211
/* Macros to map Winelib names to the correct implementation name */
/* Note that Winelib is purely Win32.                             */

212
#ifdef __WINESRC__
213 214 215 216
#define WINE_NO_UNICODE_MACROS
#endif

#ifdef WINE_NO_UNICODE_MACROS
217 218 219
# define WINELIB_NAME_AW(func) \
    func##_must_be_suffixed_with_W_or_A_in_this_context \
    func##_must_be_suffixed_with_W_or_A_in_this_context
220
#else  /* WINE_NO_UNICODE_MACROS */
221 222 223 224
# ifdef UNICODE
#  define WINELIB_NAME_AW(func) func##W
# else
#  define WINELIB_NAME_AW(func) func##A
225 226
# endif
#endif  /* WINE_NO_UNICODE_MACROS */
227

228
#ifdef WINE_NO_UNICODE_MACROS
229
# define DECL_WINELIB_TYPE_AW(type)  /* nothing */
230
#else
231
# define DECL_WINELIB_TYPE_AW(type)  typedef WINELIB_NAME_AW(type) type;
232
#endif
233

234
#include <winnt.h>
235

236 237 238 239 240 241
/* Polymorphic types */

typedef UINT_PTR        WPARAM;
typedef LONG_PTR        LPARAM;
typedef LONG_PTR        LRESULT;

242
/* Integer types */
243

244
typedef WORD            ATOM;
245 246
typedef DWORD           COLORREF, *LPCOLORREF;

247

248
/* Handle types */
249

250
typedef int HFILE;
251
DECLARE_HANDLE(HACCEL);
252 253
DECLARE_HANDLE(HBITMAP);
DECLARE_HANDLE(HBRUSH);
254
DECLARE_HANDLE(HCOLORSPACE);
255
DECLARE_HANDLE(HDC);
256
DECLARE_HANDLE(HDESK);
257
DECLARE_HANDLE(HENHMETAFILE);
258
DECLARE_HANDLE(HFONT);
259
DECLARE_HANDLE(HGLRC);
260
DECLARE_HANDLE(HHOOK);
261
DECLARE_HANDLE(HICON);
262
DECLARE_HANDLE(HINSTANCE);
263
DECLARE_HANDLE(HKEY);
264
typedef HKEY *PHKEY;
265
DECLARE_HANDLE(HKL);
266
DECLARE_HANDLE(HMENU);
267
DECLARE_HANDLE(HMETAFILE);
268
DECLARE_HANDLE(HMONITOR);
269
DECLARE_HANDLE(HPALETTE);
270 271
DECLARE_HANDLE(HPEN);
DECLARE_HANDLE(HRGN);
272
DECLARE_HANDLE(HRSRC);
273
DECLARE_HANDLE(HTASK);
274
DECLARE_HANDLE(HWINEVENTHOOK);
275
DECLARE_HANDLE(HWINSTA);
276
DECLARE_HANDLE(HWND);
277

278 279 280 281 282 283
/* Handle types that must remain interchangeable even with strict on */

typedef HINSTANCE HMODULE;
typedef HANDLE HGDIOBJ;
typedef HANDLE HGLOBAL;
typedef HANDLE HLOCAL;
284 285
typedef HANDLE GLOBALHANDLE;
typedef HANDLE LOCALHANDLE;
286
typedef HICON HCURSOR;
287

288 289
/* Callback function pointers types */

290 291 292
typedef INT_PTR (CALLBACK *FARPROC)();
typedef INT_PTR (CALLBACK *NEARPROC)();
typedef INT_PTR (CALLBACK *PROC)();
293

294

295 296
/* Macros to split words and longs. */

297 298
#define LOBYTE(w)              ((BYTE)((DWORD_PTR)(w) & 0xFF))
#define HIBYTE(w)              ((BYTE)((DWORD_PTR)(w) >> 8))
299

300 301
#define LOWORD(l)              ((WORD)((DWORD_PTR)(l) & 0xFFFF))
#define HIWORD(l)              ((WORD)((DWORD_PTR)(l) >> 16))
302

303 304
#define MAKEWORD(low,high)     ((WORD)(((BYTE)((DWORD_PTR)(low) & 0xFF)) | ((WORD)((BYTE)((DWORD_PTR)(high) & 0xFF))) << 8))
#define MAKELONG(low,high)     ((LONG)(((WORD)((DWORD_PTR)(low) & 0xFFFF)) | ((DWORD)((WORD)((DWORD_PTR)(high) & 0xFFFF))) << 16))
305

306
/* min and max macros */
307
#ifndef NOMINMAX
308
#ifndef max
309
#define max(a,b)   (((a) > (b)) ? (a) : (b))
310 311
#endif
#ifndef min
312
#define min(a,b)   (((a) < (b)) ? (a) : (b))
313
#endif
314
#endif  /* NOMINMAX */
315

316 317 318 319
#ifdef MAX_PATH /* Work-around for Mingw */ 
#undef MAX_PATH
#endif /* MAX_PATH */

320
#define MAX_PATH        260
321
#define HFILE_ERROR     ((HFILE)-1)
322

323 324 325
/* The SIZE structure */
typedef struct tagSIZE
{
326 327
    LONG cx;
    LONG cy;
328 329 330 331 332 333 334 335 336 337
} SIZE, *PSIZE, *LPSIZE;

typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;

/* The POINT structure */
typedef struct tagPOINT
{
    LONG  x;
    LONG  y;
} POINT, *PPOINT, *LPPOINT;
338 339 340

typedef struct _POINTL
{
341 342
    LONG x;
    LONG y;
343
} POINTL, *PPOINTL;
344

345 346 347 348
/* The POINTS structure */

typedef struct tagPOINTS
{
349 350 351 352
#ifdef WORDS_BIGENDIAN
    SHORT y;
    SHORT x;
#else
353 354
    SHORT x;
    SHORT y;
355
#endif
356 357
} POINTS, *PPOINTS, *LPPOINTS;

358 359 360 361 362 363 364 365 366 367 368
typedef struct _FILETIME {
#ifdef WORDS_BIGENDIAN
    DWORD  dwHighDateTime;
    DWORD  dwLowDateTime;
#else
    DWORD  dwLowDateTime;
    DWORD  dwHighDateTime;
#endif
} FILETIME, *PFILETIME, *LPFILETIME;
#define _FILETIME_

369 370 371
/* The RECT structure */
typedef struct tagRECT
{
372 373 374 375
    LONG left;
    LONG top;
    LONG right;
    LONG bottom;
376 377 378
} RECT, *PRECT, *LPRECT;
typedef const RECT *LPCRECT;

379
typedef struct _RECTL
380 381
{
    LONG left;
382
    LONG top;
383 384 385 386 387 388 389 390 391
    LONG right;
    LONG bottom;
} RECTL, *PRECTL, *LPRECTL;

typedef const RECTL *LPCRECTL;

#ifdef __cplusplus
}
#endif
392

393
#endif /* _WINDEF_ */