[devhelp] build: revert compiler flags changes, mimic again AX_COMPILER_FLAGS



commit d0fa7388a8eba51de2ea078a673c737d48e004e0
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Nov 22 13:07:39 2019 +0100

    build: revert compiler flags changes, mimic again AX_COMPILER_FLAGS
    
    I've discovered that if I remove the 'static' keyword from a local
    function definition, as in:
    
    ```
    static void
    my_local_function (void)
    {
    }
    ```
    
    then the function becomes global, without any warning!
    
    This is prevented with AX_COMPILER_FLAGS thanks to the
    -Wmissing-declarations -Wmissing-prototypes flags.
    
    And there are probably other types of warnings that were missing.
    
    --> So, mimic again AX_COMPILER_FLAGS in meson, even if it's ugly. That
    way I'm more sure that the compiler will catch important problems.
    Note that that meson code comes from me, and I'm not 100% sure that it
    perfectly mimics AX_COMPILER_FLAGS.
    
    Note that now there is the following warning:
    WARNING: Consider using the builtin warning_level option instead of
    adding warning flags by hand.
    this will be addressed by a separate commit.

 meson.build | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 2 deletions(-)
---
diff --git a/meson.build b/meson.build
index 3229081e..f6100cea 100644
--- a/meson.build
+++ b/meson.build
@@ -7,7 +7,6 @@ project(
   'devhelp', 'c',
   meson_version : '>= 0.50',
   version : '3.34.0',
-  default_options : ['warning_level=2']
 )
 
 GNOME = import('gnome')
@@ -100,14 +99,61 @@ add_project_arguments(
   language : 'c'
 )
 
-# Additional CFLAGS.
+#####
+# CFLAGS
+# Try to mimic the AX_COMPILER_FLAGS Autotools macro.
+# Some flags are missing when using only the builtin warning_level meson option,
+# even at the maximum level.
+
 warning_cflags = [
+  '-fno-strict-aliasing',
+  '-Wall',
+  '-Wextra',
+  '-Wundef',
+  '-Wnested-externs',
+  '-Wwrite-strings',
+  '-Wpointer-arith',
+  '-Wmissing-declarations',
+  '-Wmissing-prototypes',
+  '-Wstrict-prototypes',
+  '-Wredundant-decls',
   '-Wno-unused-parameter',
   '-Wno-missing-field-initializers',
+  '-Wdeclaration-after-statement',
+  '-Wformat=2',
+  '-Wold-style-definition',
+  '-Wcast-align',
+  '-Wformat-nonliteral',
+  '-Wformat-security',
+  '-Wsign-compare',
+  '-Wstrict-aliasing',
+  '-Wshadow',
+  '-Winline',
+  '-Wpacked',
+  '-Wmissing-format-attribute',
+  '-Wmissing-noreturn',
+  '-Winit-self',
+  '-Wredundant-decls',
+  '-Wmissing-include-dirs',
+  '-Wunused-but-set-variable',
+  '-Warray-bounds',
+  '-Wimplicit-function-declaration',
+  '-Wreturn-type',
+  '-Wswitch-enum',
+  '-Wswitch-default',
+  '-Wduplicated-cond',
+  '-Wduplicated-branches',
+  '-Wlogical-op',
+  '-Wrestrict',
+  '-Wnull-dereference',
+  '-Wjump-misses-init',
+  '-Wdouble-promotion'
 ]
+
 c_compiler = meson.get_compiler('c')
 supported_warning_cflags = c_compiler.get_supported_arguments(warning_cflags)
 add_project_arguments(supported_warning_cflags, language : 'c')
+##### end CFLAGS
 
 subdir('data')
 subdir('plugins/gedit-plugin')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]