Skip to content

Commit 8668c3f

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 1059999 commit 8668c3f

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
@@ -188,19 +188,28 @@ add_project_arguments(warning_flags, language: 'cpp')
188188
# MSVC: Ignore warnings that aren't really harmful, but make those
189189
# that should not be overlooked stand out.
190190
if is_msvc
191+
disable_warnings_list = [
192+
'/EHsc', # avoid warnings caused by exception handling model used
193+
]
194+
191195
# Turn off harmless warnings but make potentially dangerous ones glaring,
192196
# distributed with GLib, if available
193197
use_recommended_pragmas = cpp_compiler.get_supported_arguments('/FImsvc_recommended_pragmas.h')
194198
if use_recommended_pragmas.length() > 0
195199
add_project_arguments(use_recommended_pragmas, language: 'cpp')
196200
else
197-
disabled_warning = cpp_compiler.get_supported_arguments(['/wd4244'])
198-
add_project_arguments(disabled_warning, language: 'cpp')
201+
disable_warnings_list += '/wd4244' # 'conversion' conversion from
202+
# 'type1' to 'type2', possible loss of data
203+
endif
204+
205+
if host_machine.cpu_family() == 'x86_64' or host_machine.cpu_family() == 'aarch64'
206+
# 'var' : conversion from 'size_t' to 'type', possible loss of data (applies on 64-bit builds)
207+
disable_warnings_list += '/wd4267'
199208
endif
200-
foreach wd : ['/EHsc', '/wd4267']
201-
disabled_warning = cpp_compiler.get_supported_arguments(wd)
202-
add_project_arguments(disabled_warning, language: 'cpp')
203-
endforeach
209+
add_project_arguments(
210+
cpp_compiler.get_supported_arguments(disable_warnings_list),
211+
language: 'cpp'
212+
)
204213
endif
205214

206215
# Configure files

0 commit comments

Comments
 (0)