Search code examples
gccclangcompiler-warnings

Why isn't -Wstrict-prototypes on by default?


I learned that defining a function with a blank argument list is not the same as defining a function with void as the argument list. See ( Is it better to use C void arguments "void foo(void)" or not "void foo()"? ).

This misconception seems like a common one to me and I was surprised that neither gcc nor clang issued any warnings, even when I passed -Wall -Wextra -pedantic.

Why is this?


Solution

  • -Wall is actually only the beginning, and -Wextra not the end of the road by far.

    Instead of quoting Mr. Stallman, and having to bite down on my tongue heavily to avoid commenting on some of his more questionable opinions (like the one referred to by Thomas Dickey), I'd rather quote the current GCC manuals, emphasis mine:

    -Wall -- This enables all the warnings about constructions that some users consider questionable, and that are easy to avoid (or modify to prevent the warning), even in conjunction with macros.

    -Wextra -- This enables some extra warning flags that are not enabled by -Wall.

    So, if you say "all, plus extra", you're actually saying "easy ones, plus some". Better check that manual for more.