include/postwin.h       |    2 ++
 include/prewin.h        |   11 +++++++++++
 vcl/win/app/salinst.cxx |    9 ---------
 vcl/win/gdi/gdiimpl.cxx |    9 ---------
 vcl/win/gdi/salbmp.cxx  |    9 ---------
 5 files changed, 13 insertions(+), 27 deletions(-)

New commits:
commit c8fd1fb5535f2d8260d593631f77f1d2ed01b237
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Tue Nov 1 08:39:41 2022 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Tue Nov 1 18:27:00 2022 +0100

    -Werror,-Wunused-macros (clang-cl)
    
    ...which started to hit me now either due to building against a recent 
Visual
    Studio 2022 Preview 17.4 (which would presumably no longer define those 
macros
    in some system headers, so that the #ifndef's started to kick in now), or 
due to
    building against a more recent Windows SDK (see below), no idea which.
    
    But just dropping the seemingly unused macro definitions from the various 
.cxx
    caused builds against old Windows SDK versions like Jenkins
    <https://ci.libreoffice.org/job/gerrit_windows/139228/> to fail like
    
    > C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.18362.0\um\GdiplusTypes.h(479): error C3861: 'min': 
identifier not found
    > C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.18362.0\um\GdiplusTypes.h(480): error C3861: 'min': 
identifier not found
    > C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.18362.0\um\GdiplusTypes.h(481): error C3861: 'max': 
identifier not found
    > C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.18362.0\um\GdiplusTypes.h(482): error C3861: 'max': 
identifier not found
    > C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.18362.0\um\GdiplusTypes.h(503): error C3861: 'max': 
identifier not found
    > C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.18362.0\um\GdiplusTypes.h(504): error C3861: 'max': 
identifier not found
    > C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.18362.0\um\GdiplusTypes.h(505): error C3861: 'min': 
identifier not found
    > C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.18362.0\um\GdiplusTypes.h(506): error C3861: 'min': 
identifier not found
    > C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.18362.0\um\GdiplusTypes.h(667): error C3861: 'min': 
identifier not found
    > C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.18362.0\um\GdiplusTypes.h(668): error C3861: 'min': 
identifier not found
    > C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.18362.0\um\GdiplusTypes.h(669): error C3861: 'max': 
identifier not found
    > C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.18362.0\um\GdiplusTypes.h(670): error C3861: 'max': 
identifier not found
    > C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.18362.0\um\GdiplusTypes.h(691): error C3861: 'max': 
identifier not found
    > C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.18362.0\um\GdiplusTypes.h(692): error C3861: 'max': 
identifier not found
    > C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.18362.0\um\GdiplusTypes.h(693): error C3861: 'min': 
identifier not found
    > C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.18362.0\um\GdiplusTypes.h(694): error C3861: 'min': 
identifier not found
    [...]
    > make[1]: *** 
[C:/cygwin/home/tdf/jenkins/workspace/gerrit_windows/solenv/gbuild/LinkTarget.mk:334:
 
C:/cygwin/home/tdf/jenkins/workspace/gerrit_windows/workdir/CxxObject/vcl/win/app/salinst.o]
 Error 2
    
    so move those macro definitions to prewin.h (where they don't trigger 
clang-cl's
    -Werror,-Wunused-macros from within an include file, even if they happen to 
be
    unused in a translation unit).  (For simplicity, see whether it works in
    practice to drop those #ifndef wrappers.  If they turn out to be relevant 
for
    some build scenarios after all, they can be added back.)
    
    Change-Id: I76d8794ae2de310bdca420e5488db2bc19de23ca
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142090
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

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 <commctrl.h>
 
+// 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 <desktop/crashreport.hxx>
 
-#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 <prewin.h>
 
 #include <gdiplus.h>
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 <win/salids.hrc>
 #include <ControlCacheKey.hxx>
 
-#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 <prewin.h>
 
 #include <gdiplus.h>
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 <tools/helpers.hxx>
 #include <map>
 
-#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 <prewin.h>
 #include <gdiplus.h>
 #include <postwin.h>

Reply via email to