07 – Make good use of compiler warnings

Table of Contents

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++



Implementation effort



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:

  • 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


    -Wall -Wextra

Visual Studio:


Post history - Last 5 commits

17/02/2020 10:37:09 - be more specific (Frank Meerkötter)

14/02/2020 14:08:33 - Give all tools a number prefix to allow for sorting The number prefix is the same as the card number. (Frank Meerkötter)

Leave a Reply

Your email address will not be published. Required fields are marked *

Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on xing
Share on email
Share on stumbleupon
Share on whatsapp
Share on pocket