Recommended -W flags for building C++ with gcc
Don't forget -Wstrict-aliasing
.
I found this post was good, look the params up: Recommended gcc warning options for C
-Wall -Wextra
tends to cover the really noteworthy ones. Personally, I also like to compile with -ansi -pedantic
and occasionally -Wshadow
.
Also, it can be a little noisy and not useful 100% of the time, but -Weffc++
sometimes has good suggestions for better code quality as well.
EDIT In the age of modern C++, you should replace -ansi -pedantic
with -std=c++14 -pedantic
or whatever your version of choice is, since -ansi
will put the compiler into C++98/C++-03 mode.