windef.h 9.46 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
#if defined(__x86_64__) && !defined(_WIN64)
41 42 43
#define _WIN64
#endif

44 45 46 47 48 49 50 51 52
#ifndef _WIN64
# if defined(__i386__) && !defined(_X86_)
#  define _X86_
# endif
# if defined(_X86_) && !defined(__i386__)
#  define __i386__
# endif
#endif

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

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

87 88 89 90 91 92 93 94 95 96 97 98
#ifndef __ms_va_list
# if defined(__x86_64__) && defined (__GNUC__)
#  define __ms_va_list __builtin_ms_va_list
#  define __ms_va_start(list,arg) __builtin_ms_va_start(list,arg)
#  define __ms_va_end(list) __builtin_ms_va_end(list)
# else
#  define __ms_va_list va_list
#  define __ms_va_start(list,arg) va_start(list,arg)
#  define __ms_va_end(list) va_end(list)
# endif
#endif

99 100 101 102 103
#ifdef __WINESRC__
#define __ONLY_IN_WINELIB(x)	do_not_use_this_in_wine
#else
#define __ONLY_IN_WINELIB(x)	x
#endif
104 105

#ifndef pascal
106
#define pascal      __ONLY_IN_WINELIB(__stdcall)
107 108
#endif
#ifndef _pascal
109
#define _pascal	    __ONLY_IN_WINELIB(__stdcall)
110 111
#endif
#ifndef _stdcall
112
#define _stdcall    __ONLY_IN_WINELIB(__stdcall)
113 114
#endif
#ifndef _fastcall
115
#define _fastcall   __ONLY_IN_WINELIB(__stdcall)
116 117
#endif
#ifndef __fastcall
118
#define __fastcall  __ONLY_IN_WINELIB(__stdcall)
119 120
#endif
#ifndef __export
121
#define __export    __ONLY_IN_WINELIB(__stdcall)
122 123
#endif
#ifndef cdecl
124
#define cdecl       __ONLY_IN_WINELIB(__cdecl)
125 126
#endif
#ifndef _cdecl
127
#define _cdecl      __ONLY_IN_WINELIB(__cdecl)
128 129 130
#endif

#ifndef near
131
#define near        __ONLY_IN_WINELIB(/* nothing */)
132 133
#endif
#ifndef far
134
#define far         __ONLY_IN_WINELIB(/* nothing */)
135 136
#endif
#ifndef _near
137
#define _near       __ONLY_IN_WINELIB(/* nothing */)
138 139
#endif
#ifndef _far
140
#define _far        __ONLY_IN_WINELIB(/* nothing */)
141 142
#endif
#ifndef NEAR
143
#define NEAR        __ONLY_IN_WINELIB(/* nothing */)
144 145
#endif
#ifndef FAR
146
#define FAR         __ONLY_IN_WINELIB(/* nothing */)
147 148
#endif

149 150
#ifndef _MSC_VER
# ifndef _declspec
151
#  define _declspec(x)    __ONLY_IN_WINELIB(/* nothing */)
152 153
# endif
# ifndef __declspec
154
#  define __declspec(x)   __ONLY_IN_WINELIB(/* nothing */)
155
# endif
156 157
#endif

158 159 160 161
#ifdef _MSC_VER
# define inline __inline
#endif

162 163 164 165 166 167 168 169 170
#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
171

172
/* Misc. constants. */
173

174
#undef NULL
175
#ifdef __cplusplus
176 177 178 179 180 181 182
#define NULL  0
#else
#define NULL  ((void*)0)
#endif

#ifdef FALSE
#undef FALSE
183
#endif
184
#define FALSE 0
185

186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
#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;
214 215
typedef float           FLOAT,      *PFLOAT;
typedef char                        *PSZ;
216
#ifdef _MSC_VER
217 218 219
typedef long                                   *LPLONG;
typedef unsigned long   DWORD,      *PDWORD,   *LPDWORD;
typedef unsigned long   ULONG,      *PULONG;
220 221 222 223
#else
typedef int                                    *LPLONG;
typedef unsigned int    DWORD,      *PDWORD,   *LPDWORD;
typedef unsigned int    ULONG,      *PULONG;
224
#endif
225

226 227 228
/* Macros to map Winelib names to the correct implementation name */
/* Note that Winelib is purely Win32.                             */

229
#ifdef __WINESRC__
230 231 232 233
#define WINE_NO_UNICODE_MACROS
#endif

#ifdef WINE_NO_UNICODE_MACROS
234 235 236
# 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
237
#else  /* WINE_NO_UNICODE_MACROS */
238 239 240 241
# ifdef UNICODE
#  define WINELIB_NAME_AW(func) func##W
# else
#  define WINELIB_NAME_AW(func) func##A
242 243
# endif
#endif  /* WINE_NO_UNICODE_MACROS */
244

245
#ifdef WINE_NO_UNICODE_MACROS
246
# define DECL_WINELIB_TYPE_AW(type)  /* nothing */
247
#else
248
# define DECL_WINELIB_TYPE_AW(type)  typedef WINELIB_NAME_AW(type) type;
249
#endif
250

251
#include <winnt.h>
252

253 254 255 256 257 258
/* Polymorphic types */

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

259
/* Integer types */
260

261
typedef WORD            ATOM;
262 263
typedef DWORD           COLORREF, *LPCOLORREF;

264

265
/* Handle types */
266

267
typedef int HFILE;
268
DECLARE_HANDLE(HACCEL);
269 270
DECLARE_HANDLE(HBITMAP);
DECLARE_HANDLE(HBRUSH);
271
DECLARE_HANDLE(HCOLORSPACE);
272
DECLARE_HANDLE(HDC);
273
DECLARE_HANDLE(HDESK);
274
DECLARE_HANDLE(HENHMETAFILE);
275
DECLARE_HANDLE(HFONT);
276
DECLARE_HANDLE(HGLRC);
277
DECLARE_HANDLE(HHOOK);
278
DECLARE_HANDLE(HICON);
279
DECLARE_HANDLE(HINSTANCE);
280
DECLARE_HANDLE(HKEY);
281
typedef HKEY *PHKEY;
282
DECLARE_HANDLE(HKL);
283
DECLARE_HANDLE(HMENU);
284
DECLARE_HANDLE(HMETAFILE);
285
DECLARE_HANDLE(HMONITOR);
286
DECLARE_HANDLE(HPALETTE);
287 288
DECLARE_HANDLE(HPEN);
DECLARE_HANDLE(HRGN);
289
DECLARE_HANDLE(HRSRC);
290
DECLARE_HANDLE(HTASK);
291
DECLARE_HANDLE(HWINEVENTHOOK);
292
DECLARE_HANDLE(HWINSTA);
293
DECLARE_HANDLE(HWND);
294

295 296 297 298 299 300
/* Handle types that must remain interchangeable even with strict on */

typedef HINSTANCE HMODULE;
typedef HANDLE HGDIOBJ;
typedef HANDLE HGLOBAL;
typedef HANDLE HLOCAL;
301 302
typedef HANDLE GLOBALHANDLE;
typedef HANDLE LOCALHANDLE;
303
typedef HICON HCURSOR;
304

305 306
/* Callback function pointers types */

307 308 309
typedef INT_PTR (CALLBACK *FARPROC)();
typedef INT_PTR (CALLBACK *NEARPROC)();
typedef INT_PTR (CALLBACK *PROC)();
310

311

312 313
/* Macros to split words and longs. */

314 315
#define LOBYTE(w)              ((BYTE)((DWORD_PTR)(w) & 0xFF))
#define HIBYTE(w)              ((BYTE)((DWORD_PTR)(w) >> 8))
316

317 318
#define LOWORD(l)              ((WORD)((DWORD_PTR)(l) & 0xFFFF))
#define HIWORD(l)              ((WORD)((DWORD_PTR)(l) >> 16))
319

320 321
#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))
322

323
/* min and max macros */
324
#ifndef NOMINMAX
325
#ifndef max
326
#define max(a,b)   (((a) > (b)) ? (a) : (b))
327 328
#endif
#ifndef min
329
#define min(a,b)   (((a) < (b)) ? (a) : (b))
330
#endif
331
#endif  /* NOMINMAX */
332

333 334 335 336
#ifdef MAX_PATH /* Work-around for Mingw */ 
#undef MAX_PATH
#endif /* MAX_PATH */

337
#define MAX_PATH        260
338
#define HFILE_ERROR     ((HFILE)-1)
339

340 341 342
/* The SIZE structure */
typedef struct tagSIZE
{
343 344
    LONG cx;
    LONG cy;
345 346 347 348 349 350 351 352 353 354
} SIZE, *PSIZE, *LPSIZE;

typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;

/* The POINT structure */
typedef struct tagPOINT
{
    LONG  x;
    LONG  y;
} POINT, *PPOINT, *LPPOINT;
355 356 357

typedef struct _POINTL
{
358 359
    LONG x;
    LONG y;
360
} POINTL, *PPOINTL;
361

362 363 364 365
/* The POINTS structure */

typedef struct tagPOINTS
{
366 367 368 369
#ifdef WORDS_BIGENDIAN
    SHORT y;
    SHORT x;
#else
370 371
    SHORT x;
    SHORT y;
372
#endif
373 374
} POINTS, *PPOINTS, *LPPOINTS;

375 376 377 378 379 380 381 382 383 384 385
typedef struct _FILETIME {
#ifdef WORDS_BIGENDIAN
    DWORD  dwHighDateTime;
    DWORD  dwLowDateTime;
#else
    DWORD  dwLowDateTime;
    DWORD  dwHighDateTime;
#endif
} FILETIME, *PFILETIME, *LPFILETIME;
#define _FILETIME_

386 387 388
/* The RECT structure */
typedef struct tagRECT
{
389 390 391 392
    LONG left;
    LONG top;
    LONG right;
    LONG bottom;
393 394 395
} RECT, *PRECT, *LPRECT;
typedef const RECT *LPCRECT;

396
typedef struct _RECTL
397 398
{
    LONG left;
399
    LONG top;
400 401 402 403 404 405 406 407 408
    LONG right;
    LONG bottom;
} RECTL, *PRECTL, *LPRECTL;

typedef const RECTL *LPCRECTL;

#ifdef __cplusplus
}
#endif
409

410
#endif /* _WINDEF_ */