[gtkmm/meson-msvc-warnings: 1/2] meson.build/MSVC: Re-order warnings-related c[xx]flags a bit




commit 922ceb84adc529a0f4eccd094ee94d9fc720ebf2
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon May 23 11:05:39 2022 +0800

    meson.build/MSVC: Re-order warnings-related c[xx]flags a bit
    
    Don't (needlessly) repeat checking for the '/utf-8' compiler flag, and
    use the `/wd4267` compiler flag only when building a 64-bit build, since
    warning C4267 only applies for 64-bit builds.
    
    Also, add a short description for the warning-related compiler flags for
    Visual Studio.

 meson.build | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/meson.build b/meson.build
index 3f4973d3..e694d370 100644
--- a/meson.build
+++ b/meson.build
@@ -227,8 +227,7 @@ use_msvc14x_toolset_ver = get_option('msvc14x-parallel-installable')
 msvc14x_toolset_ver = ''
 
 if is_msvc
-  add_project_arguments(cpp_compiler.get_supported_arguments([ '/utf-8', '/wd4828']), language: 'cpp')
-  add_project_arguments(cpp_compiler.get_supported_arguments([ '/utf-8']), language: 'c')
+  add_project_arguments(cpp_compiler.get_supported_arguments([ '/utf-8', '/wd4828']), language: ['cpp','c'])
 
   if use_msvc14x_toolset_ver
     if cpp_compiler.version().version_compare('>=19.30')
@@ -288,7 +287,18 @@ gui_app_ldflags = []
 #       otherwise the program will fail to link unless we defined a WinMain()
 #       for them
 if is_msvc
-  foreach wd : ['/FImsvc_recommended_pragmas.h', '/wd4267', '/EHsc', '/wd4250', '/wd4805']
+  disable_warnings_list = [
+    '/FImsvc_recommended_pragmas.h', # Turn off harmless warnings but make potentially
+                                     # dangerous ones glaring, distributed with GLib
+    '/EHsc',  # avoid warnings caused by exception handling model used
+    '/wd4250', # 'class1' : inherits 'class2::member' via dominance
+    '/wd4805' # unsafe mix of type 'type' and type 'type' in operation
+  ]
+  if host_machine.cpu_family() == 'x86_64' or host_machine.cpu_family() == 'aarch64'
+  # 'var' : conversion from 'size_t' to 'type', possible loss of data (applies on 64-bit builds)
+    disable_warnings_list += '/wd4267'
+  endif
+  foreach wd : disable_warnings_list
     disabled_warning = cpp_compiler.get_supported_arguments(wd)
     add_project_arguments(disabled_warning, language: 'cpp')
   endforeach


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]