Other than -Wall what other warnings have people found useful?
http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Warning-Options.html
Other than -Wall what other warnings have people found useful?
http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Warning-Options.html
-pedantic -Wall -Wextra -Wno-write-strings -Wno-unused-parameter
For "Hurt me plenty" mode, I leave away the -Wno...
I like to have my code warning free, especially with C++. While C compiler warnings can often be ignored, many C++ warnings show fundamental defects in the source code.
I routinely use:
This set catches a lot for people unused to it (people whose code I get to compile with those flags for the first time); it seldom gives me a problem (though -Wcast-qual is occasionally a nuisance).
Get the manual for the GCC version you use, find all warning options available, and then deactivate only those for which you have a compelling reason to do so. (For example, non-modifiable third-party headers that would give you lots of warnings otherwise.) Document those reasons. (In the Makefile or wherever you set those options.) Review the settings at regular intervalls, and whenever you upgrade your compiler.
The compiler is your friend. Warnings are your friend. Give the compiler as much chance to tell you of potential problems as possible.
The warning about uninitialized variables doesn't work unless you specify
-O
, so I include that in my list:I also use:
To catch those nasty bugs that may occur if I write code that relies on the overflow behaviour of integers.
And:
Which enables some options that are nice to have as well. Most are for C++ though.
I generally just use