Le 11/03/2011 19:37, Colomban Wendling a écrit :
Le 08/03/2011 22:29, Colomban Wendling a écrit : I'd like to commit this to the Autotools build system:
- run cppcheck on `make check`;
- enable by default, if compiler understands them, the following
warnings (discussed in other mails of this thread):
- -Werror=implicit-function-declaration
- -Werror=pointer-arith
- -Wundef
- -Wshadow
- -Wwrite-strings
After thinking a little further, I updated my flags list first to remove error= stuff to fit the discussion result, and propose a few more, extracted from -Wall:
* -Warray-bounds: warns about some out-of-bound array subscripting * -Wformat: warns about wrong format/arguments in printf-like functions * -Wimplicit-int: warns if the return type of a function is not missing * -Wimplicit-function-declaration: warns if a function is not defined * -Wnonnull: warns when passing NULL as argument marked as non-nullable * -Wpointer-arith: warns about arithmetic usage of untyped pointers * -Wreturn-type: warns about missing return values in functions * -Wsequence-point: warns when the code might result to undefined result (e.g. "a[i++] = i") * -Wshadow: warns when shadowing symbols * -Wstrict-aliasing: warns when breaking strict aliasing rules [1] * -Wstrict-overflow=1: warns when breaking strict overflow rules [1] * -Wtrigraphs: warns about trigraphs that may be interpreted * -Wundef: warns when testing undefined constants with the preprocessor * -Wuninitialized: warns when detecting use of undefined varaibles * -Wunused-value: warns when computing an unused value * -Wunused-variable: warns about unused variables * -Wwrite-strings: makes string literals constant, used to find case where string literals are used as a modifiable value, which should be avoided.
All of these but -Wpointer-arith, -Wshadow, -Wundef and -Wwrite-strings are part of GCC's -Wall. Maybe we might directly use -Wall, but it warns about some things that are not really needed, such as unused functions.
Actually, apart -Wwrite-strings, these flags don't show so much warnings :)
So (once again), do these flags seems reasonable to you?
Cheers, Colomban
[1] see GCC's manual for details ;)