2 ms·
You should identify specify diagnostics that represent situations you don't want in your code. Then use -Werror=<warning-name> for each such diagnostic. The p
by kazinator 3y ago
You should identify specify diagnostics that represent situations you don't want in your code.
Then use -Werror=<warning-name> for each such diagnostic.
The problem there is that GCC fails if you give it an option it doesn't recognize, including just a diagnostic one.
If you use -Werror=funky-new-warning, it will fail on an older GCC that doesn't have funky-new-warning.
- IshKebab 3y agoBlacklisting specific warnings is a bad idea. Instead you should `-Werror` all warnings by default and then whitelist specific ones with `-Wno-foo` of `-Wno-error=foo` if you don't care about them. To handle differences in GCC/Clang flags you just have to detect the compiler (trivial with CMake), or dictate the compiler. But only do that for your developers and CI. Don't use `-Werror` for downstream users of your project.
- deleted 3y ago[deleted]
- kazinator 3y agoSay I've decided in my project that shadowing is evil. Why wouldn't I turn on -Werror=shadow? Where is the bad idea? Including downstream. I don't want people writing me patches that trigger my pet warnings. This is entirely compatible with the idea of locally only turning on -Werror, and then disabling certain warnings that you don't intend to fix, without foisting -Werror onto downstream. You can still have non-negotiable warnings that you turn on rather than off, and those do go downstream too.
- IshKebab 3y ago> I don't want people writing me patches that trigger my pet warnings. They will fail your CI. There's no issue.
- kazinator 3y agoSure, other than that the patch compiles fine on their end, and the diagnostic is not something you are willing to disable, or address with an additional code change on top of their patch. It's better if the deal-breaker diagnostics are on for everyone, so that everyone is working in the same programming language dialect.