Treat compiler warnings as errors
Prevent problematic code from silently „creeping“ in.
Modern C and C++ compilers are quite good at generating warnings for problematic issues. By default a warning will not stop the compiler from generating code. Consider to treat compiler warnings as errors to prevent issues from creeping into your code base.
C, C++, Qt
Minor, given that your project is already compiling without warnings.
All projects with a clearly defined target toolchain.
- Treating warnings as errors can be a considerable headache if there is a large range of toolchains/platforms to support as warnings generated might change over time.
- Do not enable „warning as errors“ for releases that are consumed by an undefined and wide-ranging user base (for example when releasing software with-in your organization, to customers or as open source).
- Visual Studio:
/WXswitch or „Treat Warnings as Errors“ in project properties
- Newer compiler versions tend to emit more warnings. The same compiler targeting a different platform might generate slightly different warnings. Make sure there is a central build flag as an escape hatch. Have a CI system in place to enforce „warnings as errors“ for your officially supported toolchain(s).