]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
meson: Make room for C++-only warning flags for MSVC
authorPeter Eisentraut <peter@eisentraut.org>
Tue, 31 Mar 2026 06:38:24 +0000 (08:38 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Tue, 31 Mar 2026 06:42:22 +0000 (08:42 +0200)
Refactor the MSVC warning option handling to have a list of common
flags and lists of flags specific to C and C++.

Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/CAGECzQR21OnnKiZO_1rLWO0-16kg1JBxnVq-wymYW0-_1cUNtg%40mail.gmail.com

meson.build

index 0ee772cd475873d533eefd77f4bd8c49d4d28b49..cfd9cc2890de7ef409441eca084a8272408026c2 100644 (file)
@@ -2297,27 +2297,42 @@ endforeach
 
 
 if cc.get_id() == 'msvc'
-  cflags_warn += [
+  msvc_common_warning_flags = [
+    # Disable warnings in system headers
+    '/external:anglebrackets',
+    '/external:W0',
+
     # Warnings to disable:
-    # from /W1:
-    '/wd4090', # different 'modifier' qualifiers
     # from /W2:
     '/wd4244', # conversion from 'type1' to 'type2', possible loss of data
+
+    # Additional warnings to enable:
+    '/w24062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled [like -Wswitch]
+    '/w24102', # unreferenced label [like -Wunused-label]
+  ]
+
+  msvc_c_warning_flags = [
+    # Warnings to disable:
+    # from /W1:
+    '/wd4090', # different 'modifier' qualifiers
     # from /W3:
     '/wd4018', # signed/unsigned mismatch
     '/wd4101', # unreferenced local variable [like -Wunused-variable, but there is no "unused" attribute, so too noisy]
     '/wd4267', # conversion from 'size_t' to 'type', possible loss of data
 
     # Additional warnings to enable:
-    '/w24062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled [like -Wswitch]
-    '/w24102', # unreferenced label [like -Wunused-label]
     '/w24255', # 'function' : no function prototype given: converting '()' to '(void)' [like -Wstrict-prototypes]
+  ]
 
-    # Disable warnings in system headers
-    '/external:anglebrackets',
-    '/external:W0',
+  msvc_cxx_warning_flags = [
   ]
 
+  cflags_warn += msvc_common_warning_flags
+  cflags_warn += msvc_c_warning_flags
+
+  cxxflags_warn += msvc_common_warning_flags
+  cxxflags_warn += msvc_cxx_warning_flags
+
   cppflags += [
     '/DWIN32',
     '/DWINDOWS',