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"
According to the cppcheck help:
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.According to the cppcheck man page, you can use the
--template
option to change the default output to include the id, e.g.You can change the output template to display the error id from the command line, which is quite neat.
For a Visual Studio format output with error id displayed, add this to your command line:
This will produce output something like this:
Which you can then suppress by adding the line:
To the previous line in the source file.
If you're using the GUI, you can right click on the message that you want to suppress to pop up a menu. Select "Copy message id". Paste the message id into your code in place of "suppressed_error_id".