[pangomm] meson/MSVC: Re-organize warning-related compiler flags



commit 6bf3981e76a4fa14d103e7c8186479d8ce53c914
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon May 23 17:31:28 2022 +0800

    meson/MSVC: Re-organize warning-related compiler flags
    
    Add a short description for each of the warning-related compiler flags that we
    apply globally.
    
    Also, apply '/wd4267' only when we are building a 64-bit build, as that warning
    should only be related to 64-bit builds.

 meson.build | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/meson.build b/meson.build
index ee887eb..95e115f 100644
--- a/meson.build
+++ b/meson.build
@@ -238,10 +238,20 @@ add_project_arguments(warning_flags, language: 'cpp')
 # MSVC: Ignore warnings that aren't really harmful, but make those
 #       that should not be overlooked stand out.
 if is_msvc
-  foreach wd : ['/FImsvc_recommended_pragmas.h', '/wd4267', '/EHsc', '/utf-8']
-    disabled_warning = cpp_compiler.get_supported_arguments(wd)
-    add_project_arguments(disabled_warning, language: 'cpp')
-  endforeach
+  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
+    '/utf-8', # Avoid C4819 unicode conversion warnings when building on CJK locales
+  ]
+  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
+  add_project_arguments(
+    cpp_compiler.get_supported_arguments(disable_warnings_list),
+    language: 'cpp'
+  )
 endif
 
 # add_dist_script() is not allowed in a subproject if meson.version() < 0.58.0.


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