3 ms·
I used to have an environment variable defined $W_REALLY_ALL that turned on, really, all the warnings. It always drove me nuts that -Wall didn’t turn them all o
by lumb63 3y ago
I used to have an environment variable defined $W_REALLY_ALL that turned on, really, all the warnings. It always drove me nuts that -Wall didn’t turn them all on and even -Wextra was insufficient. There are really very few false positives in the environments I’ve worked.
- HexDecOctBin 3y agoClang has -Weverything that I almost always turn on.
- spc476 3y agoAnd then you get warnings about structures being padded and warnings about structures not being padded.
- Longhanks 3y agoEasy to opt out via -Wno-padding. I strongly prefer clang‘s -Weverything -Wno-c++98compat -Wno-c++98-compat-pedantic -Wno-padded to gcc‘s -Wall -Wextra -Wyes-really-every-single-one -Walso-this -Wjust-turn-it-all-on-please -Walso-this-obscure -Wetc -Ware-you-getting-it
- account42 3y agoExcept if you already have all the flags for GCC then adding a few more for Clang-specific warnings isn't much of a problem.
- kevin_thibedeau 3y agoA lot of them are excessively pedantic. It is extremely for callbacks to have unused arguments. There is no point in writing extra code just to nullify ineffectual warnings. These are tools that serve us not the other way around.
- lumb63 3y agoThat's true. There are some that are pedantic (-Wpedantic, anyone?) and excessive, but I find it's easier to evaluate those on a case-by-case basis, or opt-out of the ones that are generally useless, than it is to ignore an entire class of warnings. For instance, a lot of projects I've worked on prefer to be ready for the day if/when the code has to be compiled with a different compiler, so -Wpedantic is great.
- account42 3y agoUnused parameter warnings are pretty useful to remind you when a parameter is no longer needed after you change things or to catch some mispellings / missing code. You can always cast to (void) to "use" an otherwise uneeded parameter or remove the parameter name (or comment it out to keep tools checking declaration and definition name matches happy) keeping only the type.
- theresistor 3y agoClang doesn't turn on all warnings with -Wall because a lot of projects turn on -Wall -Werror by default, and then get mad when compiler updates break their builds. So -Wall -Werror has to remain reasonably stable release-over-release.
- zvr 3y agoI have a script for this, so I can use "gccw" instead of "gcc". Updated for gcc-13.1.0: https://gist.github.com/zvr/3814cc3e5b2b54e90320c09e9d074e64 https://gist.github.com/zvr/3814cc3e5b2b54e90320c09e9d074e64