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.
Alexis wilke
source share