I was looking for a list of recommended g++ warning options for C++ and only could find this: Recommended gcc warning options for C and Useful GCC flags for C which are all quite C specific
-Wall and -Wextra enable most but not all of the warnings gcc can generate.
Which warnings that aren't enabled by those options especially when compiling C++ should be turned on as well?
-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.
Don't forget -Wstrict-aliasing
.
I found this post was good, look the params up: Recommended gcc warning options for C
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With