Re:My favorite C compiler flags during development
by hulitu on Sunday April 30, 2023 @05:51AM
(#35761080)
> The only way to ensure discipline and rid a large code base of warnings is to use -Werror
And this works as long as everybody has the same setup as you. This is unfortunately never the case. Kernel changes, libc changes, the compiler changes and sooner or later you will break the build.
The only way to ensure discipline and rid a large code base of warnings is to use -Werror
It may sound drastic until you're the poor intern that needs to refactor an active codebase with thousands of warning. Other than the technical debt it creates you're setting yourself up for having serious issue slipping through in all the noise.
"But some warnings might be false positives" ?
If one really must override the behavior it should be done explicitly and with a strong justification. This is possible either with a pragma[1]
or by globally[2] removing the entire warning category. [1] http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html[2] https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Warning-Options...