configure: add -Wmissing-declarations, -Wmissing-prototypes, and more
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 25 Mar 2020 22:40:02 +0000 (18:40 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 26 Mar 2020 22:01:40 +0000 (18:01 -0400)
Here's the rationale for each:

- -Wmissing-declarations: Make sure the definition of a function can
  "see" a corresponding (usually in a header file), if it isn't static.
  This makes sure that the declaration and definition don't go out of
  sync, which can lead to hard to debug problems (because it still
  builds, but the function doesn't receives what it thinks it receives).
  On top of pointing out out-of-sync declarations, it can help point out
  that a foo.c file misses including its header foo.c, or that a
  function should actually be made static.

- -Wmissing-prototypes: makes sure that functions without parameters are
  declared as `foo(void)` instead of `foo()`.  In C, the former declares
  a function that takes no parameters, whereas the latter declares a
  function without specifying its parameters.  The latter could be
  called with any number of parameters, which is a recipe for confusion.

- -Wmissing-parameter-type, -Wold-style-definition,
  -Wold-style-declarations, -Wstrict-prototypes: makes sure there's no
  function declared with parameters without types specified, or using
  the old style:

  int foo(bar)
  int bar;
  {
    ...
  }

  Unlikely, but there's no harm in enabling them.

Change-Id: I7ddf5ff61b4466c0bd7b03485ef29156c399e2a8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac

index a997ba3b9e6c62d2e6148ecb09ae1b524cabaa27..4e186d471ac4bd0f83efe85892401ae9292c3038 100644 (file)
@@ -39,6 +39,11 @@ AX_APPEND_COMPILE_FLAGS([ dnl
                dnl            ^
                -Wno-incomplete-setjmp-declaration dnl
                -Wdiscarded-qualifiers dnl
                dnl            ^
                -Wno-incomplete-setjmp-declaration dnl
                -Wdiscarded-qualifiers dnl
+               -Wmissing-declarations dnl
+               -Wmissing-prototypes dnl
+               -Wmissing-parameter-type dnl
+               -Wold-style-definition dnl
+               -Wstrict-prototypes dnl
        ],
        [WARN_CFLAGS],
        [-Werror])
        ],
        [WARN_CFLAGS],
        [-Werror])
This page took 0.034418 seconds and 4 git commands to generate.