Make good use of compiler warnings
Let the compiler warn you about problems
Modern C and C++ compilers help you to catch problems early on by emitting warnings at compile time. Make sure warnings are enabled for your project. Often there are temptations to disable them („we have so many of them“, …). Warnings are not binary, in addition to the different warning levels, individual warnings can be specifically enabled or concisely suppressed. Don’t throw out the baby with the bath water – make sure to properly configure warnings.
C and C++
All types of projects.
Existing projects: Review the project settings – make sure warnings are enabled.
Existing projects where warnings had been disabled for a long time can generate hundreds of warnings. This should be addressed It is dangerous (and potentially expensive) to work like that.
Potential way to use warning in such projects:
- Selectively disable warnings which are very noisy and not too serious.
- Review the rest.
- Communicate with the stakeholders and fix the most serious.
- Cut down on the number of disabled warnings over time.