Search code examples
c++static-analysiserror-suppressioncppcheck

How to use cppcheck's inline suppression filter option for C++ code?


I would like to use Cppcheck for static code analysis of my C++ code. I learned that I can suppress some kind of warnings with --inline-suppr command. However, I can't find what "suppressed_error_id" I should put in the comment:

// cppcheck-suppress "suppressed_error_id"

Solution

  • According to the cppcheck help:

    The error id is the id that you want to suppress. The easiest way to get it is to use the --xml command line flag. Copy and paste the id string from the xml output.

    So run cppcheck against some code that contains the error with the --xml flag, and then look in the generated XML file to find its name.