Skip to content

Commit 668310a

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 981ef91 commit 668310a

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

292302
# Configure files

0 commit comments

Comments
 (0)