Skip to content

Commit 7c8d22e

Browse files
committed
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.
1 parent 3624db5 commit 7c8d22e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

meson.build

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,20 @@ add_project_arguments(warning_flags, language: 'cpp')
282282
# MSVC: Ignore warnings that aren't really harmful, but make those
283283
# that should not be overlooked stand out.
284284
if is_msvc
285-
foreach wd : ['/FImsvc_recommended_pragmas.h', '/utf-8', '/wd4267', '/EHsc' ]
286-
disabled_warning = cpp_compiler.get_supported_arguments(wd)
287-
add_project_arguments(disabled_warning, language: 'cpp')
288-
endforeach
285+
disable_warnings_list = [
286+
'/FImsvc_recommended_pragmas.h', # Turn off harmless warnings but make potentially
287+
# dangerous ones glaring, distributed with GLib
288+
'/EHsc', # avoid warnings caused by exception handling model used
289+
'/utf-8', # Avoid C4819 unicode conversion warnings when building on CJK locales
290+
]
291+
if host_machine.cpu_family() == 'x86_64' or host_machine.cpu_family() == 'aarch64'
292+
# 'var' : conversion from 'size_t' to 'type', possible loss of data (applies on 64-bit builds)
293+
disable_warnings_list += '/wd4267'
294+
endif
295+
add_project_arguments(
296+
cpp_compiler.get_supported_arguments(disable_warnings_list),
297+
language: 'cpp'
298+
)
289299
endif
290300

291301
# Configure files

0 commit comments

Comments
 (0)