basysKom Toolbox

07 – Make good use of compiler warnings

Make good use of compiler warnings

Goals

Let the compiler warn you about problems

Description

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.

Environment

C and C++

Platform

All

Implementation effort

Low

Applicability

All types of projects.

Existing projects: Review the project settings – make sure warnings are enabled.

Caveats

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:

  • Enable -Wall
  • 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.

See also

Implementation hints

GCC/Clang:

    -Wall -Wextra

Visual Studio:

    /Wall
About the Toolbox

The basysKom Toolbox is a state-of-the-art collection of best practices in agile management and software development and a valuable tool for every kickoff meeting.

These cards can be used during a project kickoff in order to select best fitting good practices from the very start of your project, but also as a reminder during the course of a project implementation. Every card holds a QR code with additional information related to the specific tool, the tools’ applicability, known constraints and additional tips on how to implement it in a project setup.

You can provide us feedback on GitHub.

Toolbox

basysKom Newsletter

We collect only the data you enter in this form (no IP address or information that can be derived from it). The collected data is only used in order to send you our regular newsletters, from which you can unsubscribe at any point using the link at the bottom of each newsletter. We will retain this information until you ask us to delete it permanently. For more information about our privacy policy, read Privacy Policy