1
0
Эх сурвалжийг харах

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.
Christian Kellner 6 жил өмнө
parent
commit
34d86d30b1
1 өөрчлөгдсөн 48 нэмэгдсэн , 0 устгасан
  1. 48 0
      meson.build

+ 48 - 0
meson.build

@@ -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'))