diff --git a/include/postwin.h b/include/postwin.h index c6198ef21c5a..78523b87dcf8 100644 --- a/include/postwin.h +++ b/include/postwin.h @@ -51,6 +51,8 @@ #undef WB_LEFT #undef WB_RIGHT #undef Yield +#undef max #undef mciSetCommand +#undef min /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/prewin.h b/include/prewin.h index d6f2274451d5..3e19a842de5d 100644 --- a/include/prewin.h +++ b/include/prewin.h @@ -44,6 +44,17 @@ #include +// For some old versions of the Windows SDK, at least GidplusTypes.h (as indirectly included from +// gdiplus.h, which in turn we often include from between these prewin.h/postwin.h wrappers) expects +// pre-existing min and max. That is true for e.g. +// C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/um/GdiplusTypes.h, but not for e.g. +// C:/Program Files (x86)/Windows Kits/10/Include/10.0.22000.0/um/GdiplusTypes.h which explicitly +// defines its own GDIPLUS_MIN/MAX macros. The easiest fix appears to be to define min/max here and +// to undefin them again in postwin.h, until no supported version of the Windows SDK requires this +// hack any longer: +#define min(a, b) (((a) < (b)) ? (a) : (b)) +#define max(a, b) (((a) > (b)) ? (a) : (b)) + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx index 56773808fea5..b903247d2d85 100644 --- a/vcl/win/app/salinst.cxx +++ b/vcl/win/app/salinst.cxx @@ -64,15 +64,6 @@ #include -#if defined _MSC_VER -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif -#endif - #include #include diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx index 85020f02cb1e..81d41cf41d33 100644 --- a/vcl/win/gdi/gdiimpl.cxx +++ b/vcl/win/gdi/gdiimpl.cxx @@ -49,15 +49,6 @@ #include #include -#if defined _MSC_VER -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif -#endif - #include #include diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx index e4b0f570f671..18997f650a92 100644 --- a/vcl/win/gdi/salbmp.cxx +++ b/vcl/win/gdi/salbmp.cxx @@ -35,15 +35,6 @@ #include #include -#if defined _MSC_VER -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif -#endif - #include #include #include