Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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" 
like image 410
Blaise Avatar asked Jun 02 '10 09:06

Blaise


1 Answers

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:

--template "{file}({line}): {severity} ({id}): {message}" 

This will produce output something like this:

s:\src\jpeg.cpp(123): error (bufferAccessOutOfBounds): Buffer access out-of-bounds: abRY 

Which you can then suppress by adding the line:

// cppcheck-suppress bufferAccessOutOfBounds 

To the previous line in the source file.

like image 51
Andy Krouwel Avatar answered Oct 01 '22 09:10

Andy Krouwel