Recommended gcc warning options for C

Sard picture Sard · Sep 30, 2008 · Viewed 32.7k times · Source

Other than -Wall what other warnings have people found useful?

http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Warning-Options.html

Answer

Jonathan Leffler picture Jonathan Leffler · Sep 30, 2008

I routinely use:

    gcc -m64 -std=c99 -pedantic -Wall -Wshadow -Wpointer-arith -Wcast-qual \
        -Wstrict-prototypes -Wmissing-prototypes

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).