Skip to content

Commit 1496ebb

Browse files
committed
Meson/MSVC: Re-organize warnings-related compiler flags
Add a short description for each of the warnings-related compiler flags that we are using. Also, only apply '/wd4267' for 64-bit builds, since it is a warning that should only be related to 64-bit builds.
1 parent 063a96f commit 1496ebb

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

meson.build

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,19 +184,28 @@ add_project_arguments(warning_flags, language: 'cpp')
184184
# MSVC: Ignore warnings that aren't really harmful, but make those
185185
# that should not be overlooked stand out.
186186
if is_msvc
187+
disable_warnings_list = [
188+
'/EHsc', # avoid warnings caused by exception handling model used
189+
]
190+
187191
# Turn off harmless warnings but make potentially dangerous ones glaring,
188192
# distributed with GLib, if available
189193
use_recommended_pragmas = cpp_compiler.get_supported_arguments('/FImsvc_recommended_pragmas.h')
190194
if use_recommended_pragmas.length() > 0
191195
add_project_arguments(use_recommended_pragmas, language: 'cpp')
192196
else
193-
disabled_warning = cpp_compiler.get_supported_arguments(['/wd4244'])
194-
add_project_arguments(disabled_warning, language: 'cpp')
197+
disable_warnings_list += '/wd4244' # 'conversion' conversion from
198+
# 'type1' to 'type2', possible loss of data
199+
endif
200+
201+
if host_machine.cpu_family() == 'x86_64' or host_machine.cpu_family() == 'aarch64'
202+
# 'var' : conversion from 'size_t' to 'type', possible loss of data (applies on 64-bit builds)
203+
disable_warnings_list += '/wd4267'
195204
endif
196-
foreach wd : ['/EHsc', '/wd4267']
197-
disabled_warning = cpp_compiler.get_supported_arguments(wd)
198-
add_project_arguments(disabled_warning, language: 'cpp')
199-
endforeach
205+
add_project_arguments(
206+
cpp_compiler.get_supported_arguments(disable_warnings_list),
207+
language: 'cpp'
208+
)
200209
endif
201210

202211
# Configure files

0 commit comments

Comments
 (0)