How to enable the highest warning level in the GCC compiler (Boost is heavily used)

I just read a book recommending that you enable the highest warning level in GCC. I am just checking a document on the Internet and found that there are too many options. I want to enable the highest warning level, which parameter should I use?

And we intensively use Boost in our project.

+7
c ++ gcc compiler-construction boost warnings
source share
2 answers

Unlike cl, which has 4 levels, gcc has only a set of options that you can turn on or off.

As others have mentioned, the -Wall value is the default value that already includes many warnings. The -pedantic option adds a few more. And -Wextra is another group ...

But to really capture a lot of warnings, you have to add a lot manually.

There is a kit that I like to use, although someone told me that some of them are contradictory, I think the list is pretty good for my development:

-Werror -Wall -Wextra -pedantic -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wundef -Wno-unused -Wno-variadic-macros -Wno-parentheses -fdiagnostics-show-option

Please note that I use -Werror , because otherwise you get warnings and, as a rule, ignore them. With -Werror , ignoring nothing else! Write pristine code and your software will be more likely to work.

+10
source share

I think you can use the -Wall switch

-one
source share

All Articles