]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Disable warnings in system headers in MSVC
authorPeter Eisentraut <peter@eisentraut.org>
Wed, 25 Mar 2026 14:03:30 +0000 (15:03 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Wed, 25 Mar 2026 14:03:52 +0000 (15:03 +0100)
This is similar to the standard behavior in GCC.  For MSVC, we set all
headers in angle brackets to be considered system headers.  (GCC goes
by path, not include style.)

The required option is available since VS 2017.  (Before VS 2019
version 16.10, the additional option /experimental:external is
required, but per discussion in [0], we effectively require 16.11, so
this shouldn't be a problem.)

[0]: https://www.postgresql.org/message-id/04ab76a3-186c-4a37-8076-e6882ebf9d43%40eisentraut.org

Then, we can remove one workaround for avoiding a warning from a
system header.  (And some warnings to be enabled in the future could
benefit from this.)

Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/aa73q1aT0A3/vke/%40ip-10-97-1-34.eu-west-3.compute.internal

meson.build
src/backend/port/win32/crashdump.c

index 0a181909fab15d39d871f822c29637fa58ec5cd4..79cc7b4e758dc0bf3654c37e2363c4013831f266 100644 (file)
@@ -2309,6 +2309,10 @@ if cc.get_id() == 'msvc'
     '/w24062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled [like -Wswitch]
     '/w24102', # unreferenced label [like -Wunused-label]
     '/w24777', # 'function' : format string 'string' requires an argument of type 'type1', but variadic argument number has type 'type2' [like -Wformat]
+
+    # Disable warnings in system headers
+    '/external:anglebrackets',
+    '/external:W0',
   ]
 
   cppflags += [
index 05790ba6ac1d093ca0256fc82e229c751ab664e5..0efeb9a923605ae891ac6f23d62013a0fd68a416 100644 (file)
 
 #include "postgres.h"
 
-/*
- * Some versions of the MS SDK contain "typedef enum { ... } ;" which the MS
- * compiler quite sanely complains about. Well done, Microsoft.
- * This pragma disables the warning just while we include the header.
- * The pragma is known to work with all (as at the time of writing) supported
- * versions of MSVC.
- */
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4091)
-#endif
 #include <dbghelp.h>
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
 
 /*
  * Much of the following code is based on CodeProject and MSDN examples,