Use additional compiler warnings, if supported

Check a list of well-known compiler warnings and use the one that
are supported by the current compiler.
This commit is contained in:
Christian Kellner 2019-03-21 13:58:03 +01:00 committed by Alex Smith
parent 4a577b8c7c
commit 34d86d30b1

View File

@ -23,6 +23,54 @@ add_global_arguments(am_cflags, language: 'c')
cc = meson.get_compiler('c')
# additional compiler warnings, if supported
test_args = [
'-Waggregate-return',
'-Wunused',
'-Warray-bounds',
'-Wcast-align',
'-Wclobbered',
'-Wempty-body',
'-Wformat=2',
'-Wformat-nonliteral',
'-Wformat-signedness',
'-Wignored-qualifiers',
'-Wimplicit-function-declaration',
'-Winit-self',
'-Wmissing-format-attribute',
'-Wmissing-include-dirs',
'-Wmissing-noreturn',
'-Wmissing-parameter-type',
'-Wnested-externs',
'-Wno-discarded-qualifiers',
'-Wno-missing-field-initializers',
'-Wno-suggest-attribute=format',
'-Wno-unused-parameter',
'-Wold-style-definition',
'-Woverride-init',
'-Wpointer-arith',
'-Wredundant-decls',
'-Wreturn-type',
'-Wshadow',
'-Wsign-compare',
'-Wstrict-aliasing=3',
'-Wstrict-prototypes',
'-Wstringop-overflow',
'-Wstringop-truncation',
'-Wtype-limits',
'-Wundef',
'-Wuninitialized',
'-Wunused-but-set-variable',
'-Wwrite-strings',
]
foreach arg: test_args
if cc.has_argument(arg)
add_global_arguments(arg, language : 'c')
endif
endforeach
path_prefix = get_option('prefix')
path_bindir = join_paths(path_prefix, get_option('bindir'))
path_datadir = join_paths(path_prefix, get_option('datadir'))