On Wed, 13 Dec 2000, David Elliott wrote: > In order to allow __cdecl and __stdcall to be defined correctly without > including Windows headers it is necessary to split their definition out into > a new include file. This include file is then included into windef.h in the > same place it was before. This include file will also be included in the > msvcrt headers so that they don't have to include all of windef.h just to > get the definition of __cdecl and __stdcall. I made a similar proposal to Alexandre recently but he wasn't too hot. One difference is that I chose to isolate all the things that would normally be provided by the compiler on Windows, and a few widely used very basic Wine-specific items, not just the calling convention macros. I had: - CPU macros (as part of the calling convetion, maybe it should be handled separately) - calling convention - anonymous struct/unions - ANSI/Unicode type/prototype support (the _AW macros) - Macros for structure packing (actually WINE_UNUSED, WINE_PACKED, ...) I called the new file 'wine/winedef.h' and I expected that it might be used in other Windows headers, should it turn out that one of them is not supposed to include 'windef.h'. But I actually don't know of such a header (except the C headers), so my case was a bit weak. I attached it so that you can have a look at it. Maybe I should revive it? -- Francois Gouget [EMAIL PROTECTED] http://fgouget.free.fr/ Any sufficiently advanced Operating System is indistinguishable from Linux
Index: include/windef.h =================================================================== RCS file: /home/wine/wine/include/windef.h,v retrieving revision 1.43 diff -u -r1.43 windef.h --- include/windef.h 2000/11/25 01:21:22 1.43 +++ include/windef.h 2000/12/12 21:04:51 @@ -15,6 +15,8 @@ extern "C" { #endif +#include "wine/winedef.h" + /* Misc. constants. */ #define WINVER 0x0500 @@ -34,120 +36,29 @@ #endif #define NULL 0 -/* Macros to map Winelib names to the correct implementation name */ -/* depending on __WINE__ and UNICODE macros. */ -/* Note that Winelib is purely Win32. */ - -#ifdef __WINE__ -# 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 -#else /* __WINE__ */ -# ifdef UNICODE -# define WINELIB_NAME_AW(func) func##W -# else -# define WINELIB_NAME_AW(func) func##A -# endif /* UNICODE */ -#endif /* __WINE__ */ - -#ifdef __WINE__ -# define DECL_WINELIB_TYPE_AW(type) /* nothing */ -#else /* __WINE__ */ -# define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type; -#endif /* __WINE__ */ - -#ifdef __WINE__ -# define NONAMELESSSTRUCT -# define NONAMELESSUNION -#else -/* Anonymous struct support starts with gcc/g++ 2.96 */ -# if !defined(NONAMELESSSTRUCT) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ < 96))) -# define NONAMELESSSTRUCT -# endif -/* Anonymous unions support starts with gcc 2.96/g++ 2.95 */ -# if !defined(NONAMELESSUNION) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ < 95) || ((__GNUC_MINOR__ == 95) && !defined(__cplusplus))))) -# define NONAMELESSUNION -# endif -#endif -#ifndef NONAMELESSSTRUCT -#define DUMMYSTRUCTNAME -#define DUMMYSTRUCTNAME1 -#define DUMMYSTRUCTNAME2 -#define DUMMYSTRUCTNAME3 -#define DUMMYSTRUCTNAME4 -#define DUMMYSTRUCTNAME5 -#else /* !defined(NONAMELESSSTRUCT) */ -#define DUMMYSTRUCTNAME s -#define DUMMYSTRUCTNAME1 s1 -#define DUMMYSTRUCTNAME2 s2 -#define DUMMYSTRUCTNAME3 s3 -#define DUMMYSTRUCTNAME4 s4 -#define DUMMYSTRUCTNAME5 s5 -#endif /* !defined(NONAMELESSSTRUCT) */ - -#ifndef NONAMELESSUNION -#define DUMMYUNIONNAME -#define DUMMYUNIONNAME1 -#define DUMMYUNIONNAME2 -#define DUMMYUNIONNAME3 -#define DUMMYUNIONNAME4 -#define DUMMYUNIONNAME5 -#define DUMMYUNIONNAME6 -#define DUMMYUNIONNAME7 -#define DUMMYUNIONNAME8 -#else /* !defined(NONAMELESSUNION) */ -#define DUMMYUNIONNAME u -#define DUMMYUNIONNAME1 u1 -#define DUMMYUNIONNAME2 u2 -#define DUMMYUNIONNAME3 u3 -#define DUMMYUNIONNAME4 u4 -#define DUMMYUNIONNAME5 u5 -#define DUMMYUNIONNAME6 u6 -#define DUMMYUNIONNAME7 u7 -#define DUMMYUNIONNAME8 u8 -#endif /* !defined(NONAMELESSUNION) */ - -/* Calling conventions definitions */ - -#ifdef __i386__ -# ifndef _X86_ -# define _X86_ -# endif -# if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7))) -# define __stdcall __attribute__((__stdcall__)) -# define __cdecl __attribute__((__cdecl__)) -# else -# error You need gcc >= 2.7 to build Wine on a 386 -# endif /* __GNUC__ */ -#else /* __i386__ */ -# define __stdcall -# define __cdecl -#endif /* __i386__ */ +/* Calling convention definitions */ #define CALLBACK __stdcall #define WINAPI __stdcall #define APIPRIVATE __stdcall #define PASCAL __stdcall #define pascal __stdcall -#define _pascal __stdcall -#define _stdcall __stdcall -#define _fastcall __stdcall -#define __fastcall __stdcall -#define __export __stdcall #define CDECL __cdecl #define _CDECL __cdecl #define cdecl __cdecl -#define _cdecl __cdecl #define WINAPIV __cdecl #define APIENTRY WINAPI -#ifndef _declspec -#define _declspec(x) -#endif -#ifndef __declspec -#define __declspec(x) -#endif +#ifndef __WINE__ +#define NEAR +#define FAR +#define near +#define far +#define IN +#define OUT +#define OPTIONAL +#endif /* __WINE__ */ #define CONST const @@ -333,33 +244,8 @@ typedef BOOL CALLBACK (*WNDENUMPROC)(HWND,LPARAM); typedef LRESULT CALLBACK (*WNDPROC)(HWND,UINT,WPARAM,LPARAM); -/* Define some empty macros for compatibility with Windows code. */ - -#ifndef __WINE__ -#define NEAR -#define FAR -#define near -#define far -#define _near -#define _far -#define IN -#define OUT -#define OPTIONAL -#endif /* __WINE__ */ - #include "winnt.h" -/* Macro for structure packing. */ - -#ifdef __GNUC__ -#define WINE_PACKED __attribute__((packed)) -#define WINE_UNUSED __attribute__((unused)) -#define WINE_NORETURN __attribute__((noreturn)) -#else -#define WINE_PACKED /* nothing */ -#define WINE_UNUSED /* nothing */ -#define WINE_NORETURN /* nothing */ -#endif /* Macros to split words and longs. */ --- /dev/null Thu Nov 16 15:58:03 2000 +++ include/wine/winedef.h Tue Dec 12 12:26:44 2000 @@ -0,0 +1,137 @@ +#ifndef __WINE_WINE_WINEDEF_H +#define __WINE_WINE_WINEDEF_H + +/* Calling convention definitions */ + +#ifdef __i386__ +# ifndef _X86_ +# define _X86_ +# endif +# if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= +7))) +# define __stdcall __attribute__((__stdcall__)) +# define __cdecl __attribute__((__cdecl__)) +# else +# error You need gcc >= 2.7 to build Wine on a 386 +# endif /* __GNUC__ */ +#else /* __i386__ */ +# define __stdcall +# define __cdecl +#endif /* __i386__ */ + +#ifndef __WINE__ +/* Various synonyms, should not be used in Wine */ +#define _pascal __stdcall +#define _stdcall __stdcall +#define _fastcall __stdcall +#define __fastcall __stdcall +#define __export __stdcall +#define _cdecl __cdecl +#define _near +#define _far +#endif /* __WINE__ */ + +#ifndef _declspec +#define _declspec(x) +#endif +#ifndef __declspec +#define __declspec(x) +#endif + + + +/* Anonymous struct/union support */ + +#ifdef __WINE__ +# define NONAMELESSSTRUCT +# define NONAMELESSUNION +#else +/* Anonymous struct support starts with gcc/g++ 2.96 */ +# if !defined(NONAMELESSSTRUCT) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ +== 2) && (__GNUC_MINOR__ < 96))) +# define NONAMELESSSTRUCT +# endif +/* Anonymous unions support starts with gcc 2.96/g++ 2.95 */ +# if !defined(NONAMELESSUNION) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ +== 2) && ((__GNUC_MINOR__ < 95) || ((__GNUC_MINOR__ == 95) && +!defined(__cplusplus))))) +# define NONAMELESSUNION +# endif +#endif + +#ifndef NONAMELESSSTRUCT +#define DUMMYSTRUCTNAME +#define DUMMYSTRUCTNAME1 +#define DUMMYSTRUCTNAME2 +#define DUMMYSTRUCTNAME3 +#define DUMMYSTRUCTNAME4 +#define DUMMYSTRUCTNAME5 +#else /* !defined(NONAMELESSSTRUCT) */ +#define DUMMYSTRUCTNAME s +#define DUMMYSTRUCTNAME1 s1 +#define DUMMYSTRUCTNAME2 s2 +#define DUMMYSTRUCTNAME3 s3 +#define DUMMYSTRUCTNAME4 s4 +#define DUMMYSTRUCTNAME5 s5 +#endif /* !defined(NONAMELESSSTRUCT) */ + +#ifndef NONAMELESSUNION +#define DUMMYUNIONNAME +#define DUMMYUNIONNAME1 +#define DUMMYUNIONNAME2 +#define DUMMYUNIONNAME3 +#define DUMMYUNIONNAME4 +#define DUMMYUNIONNAME5 +#define DUMMYUNIONNAME6 +#define DUMMYUNIONNAME7 +#define DUMMYUNIONNAME8 +#else /* !defined(NONAMELESSUNION) */ +#define DUMMYUNIONNAME u +#define DUMMYUNIONNAME1 u1 +#define DUMMYUNIONNAME2 u2 +#define DUMMYUNIONNAME3 u3 +#define DUMMYUNIONNAME4 u4 +#define DUMMYUNIONNAME5 u5 +#define DUMMYUNIONNAME6 u6 +#define DUMMYUNIONNAME7 u7 +#define DUMMYUNIONNAME8 u8 +#endif /* !defined(NONAMELESSUNION) */ + + + +/* ANSI/Unicode type/prototype support */ + +/* Macros to map Winelib names to the correct implementation + * name depending on __WINE__ and UNICODE macros. + * Note that Winelib is purely Win32. + */ + +#ifdef __WINE__ +# 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 +#else /* __WINE__ */ +# ifdef UNICODE +# define WINELIB_NAME_AW(func) func##W +# else +# define WINELIB_NAME_AW(func) func##A +# endif /* UNICODE */ +#endif /* __WINE__ */ + +#ifdef __WINE__ +# define DECL_WINELIB_TYPE_AW(type) /* nothing */ +#else /* __WINE__ */ +# define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type; +#endif /* __WINE__ */ + + + +/* Macro for structure packing. */ + +#ifdef __GNUC__ +#define WINE_PACKED __attribute__((packed)) +#define WINE_UNUSED __attribute__((unused)) +#define WINE_NORETURN __attribute__((noreturn)) +#else +#define WINE_PACKED /* nothing */ +#define WINE_UNUSED /* nothing */ +#define WINE_NORETURN /* nothing */ +#endif + +#endif /* __WINE_WINE_WINEDEF_H */