From 1defe6b37c23941fe2a67ad4fa66e8ab5f37f9b3 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Fri, 5 Jun 2009 18:04:58 +0100 Subject: Cygwin/X: Don't destroy min/max macros in Xwindows.h Now that macros named min/max rather than MIN/MAX are used consistently in the X server, we need to ensure they work for Xwin builds. Change Xwindows.h from simply destroying any definition of min/max, to avoiding defining them but allowing any pre-existing definition to stand. Also, try to improve the comment describing why this madness is needed in the first place, and remove a no-longer needed macro definition of sleep() --- Xwindows.h | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'Xwindows.h') diff --git a/Xwindows.h b/Xwindows.h index 8364952..b14c8bc 100644 --- a/Xwindows.h +++ b/Xwindows.h @@ -28,18 +28,29 @@ The Open Group. */ /* - * This header file has for sole purpose to allow to include windows.h - * without getting any name conflicts with our code. - * Conflicts come from the fact that including windows.h actually pulls - * in the whole Windows API... + * This header file has the sole purpose of allowing the inclusion of + * windows.h without getting any name conflicts with X headers code, by + * renaming the conflicting definitions from windows.h + * + * Some (non-Microsoft) versions of the Windows API headers actually avoid + * making the conflicting definitions if XFree86Server is defined, so we + * need to remember if that was defined and undefine it during including + * windows.h (so the conflicting definitions get wrapped correctly), and + * then redefine it afterwards... + * + * There doesn't seem to be a good way to wrap the min/max macros from + * windows.h, so we simply avoid defining them completely, allowing any + * pre-existing definition to stand. + * */ #undef _XFree86Server -#ifdef XFree86Server +#ifdef XFree86Server #define _XFree86Server #undef XFree86Server #endif +#define NOMINMAX #define BOOL wBOOL #define INT32 wINT32 #undef Status @@ -48,6 +59,7 @@ The Open Group. #define BYTE wBYTE #define FreeResource wFreeResource #include +#undef NOMINMAX #undef Status #define Status int #undef BYTE @@ -56,8 +68,6 @@ The Open Group. #undef ATOM #undef FreeResource #undef CreateWindowA -#undef min -#undef max #ifdef RESOURCE_H #undef RT_FONT @@ -66,8 +76,6 @@ The Open Group. #define RT_CURSOR ((RESTYPE)5) #endif -#define sleep(x) Sleep((x) * 1000) - #if defined(WIN32) && (!defined(PATH_MAX) || PATH_MAX < 1024) #undef PATH_MAX #define PATH_MAX 1024 -- cgit v1.2.3