On 11.07.26 17:18, Tom Lane wrote:
Peter Eisentraut <[email protected]> writes:
I know you have already reported this upstream, but here are some
patches to silence the resulting warnings on MSVC.

Since Eggert doesn't seem to want to do anything about these,
I was planning on just ignoring them (and have already adjusted
my warning-scraping script to do so).  I don't think inserting
diffs from tzdb upstream is a good tradeoff, so I definitely
don't like your 0001.  I'd be okay with 0002's solution (suppress
the unary-minus complaint globally).  I might hold my nose for
0003, but you say it doesn't seem to work, so ...

How about we just disable these warnings for this file, as in the attached patch.
From ef684fa6ea2f832ba97d39a1ffef6a7c084ddd9e Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Mon, 3 Aug 2026 11:55:28 +0200
Subject: [PATCH v2] Fix MSVC warnings from new timezone code

The new timezone code from commit aeb07c55fab introduced a few new
compiler warnings from MSVC:

    ../src/timezone/zic.c(353): warning C5287: operands are different enum 
types '<unnamed-enum-RF_NAME>' and '<unnamed-enum-LF_TARGET>'; use an explicit 
cast to silence this warning
    ../src/timezone/zic.c(353): warning C5287: operands are different enum 
types '<unnamed-enum-RF_NAME>' and '<unnamed-enum-LP_YEAR>'; use an explicit 
cast to silence this warning
    ../src/timezone/zic.c(1654): warning C4146: unary minus operator applied to 
unsigned type, result still unsigned

Silence these warnings with pragmas.

In order not to make future code merges more complicated, the pragmas
apply to the entire file, not only to the specific code sections where
they are needed.  This also prevents further warnings of the same
kinds creeping in.

Discussion: 
https://www.postgresql.org/message-id/flat/2294297.1780270682%40sss.pgh.pa.us
---
 src/timezone/zic.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/timezone/zic.c b/src/timezone/zic.c
index cc6550bdb14..a1256ca49c2 100644
--- a/src/timezone/zic.c
+++ b/src/timezone/zic.c
@@ -10,6 +10,17 @@
 
 #include "postgres_fe.h"
 
+/*
+ * Disable some warnings on MSVC.  See also
+ * 
<https://lists.iana.org/hyperkitty/list/[email protected]/thread/PJBVERYHQZEXIREYIHC5OJGZMNVQC2SD/>.
+ */
+#ifdef _MSC_VER
+/* warning C4146: unary minus operator applied to unsigned type, result still 
unsigned */
+#pragma warning(disable: 4146)
+/* warning C5287: operands are different enum types */
+#pragma warning(disable: 5287)
+#endif
+
 #include <fcntl.h>
 #include <grp.h>
 #include <pwd.h>
-- 
2.55.0

Reply via email to