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 find what "suppressed_error_id" I should put in the comment: // cppcheck-suppress "suppressed_error_id"
+2
A:
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.
anon
2010-06-02 09:25:30
Hey, thanks for quick answer, however the tip you gave works for --suppression option put in a separate file. I tried to achieve the same thing with comments just in my code, without luck so far with the use of these ids. Perhaps, the ids are OK and the problem lies elsewhere.
blz
2010-06-02 10:48:37
@btz what makes you think cppcheck suports putting command line switches in code comments?
anon
2010-06-02 10:54:40
I run ./cppcheck --help and saw --inline-suppr option:--inline-suppr Enable inline suppressions. Use them by placing one or more comments in the form: // cppcheck-suppress memleak on the lines before the warning to suppress.Tried to use it in my code (running cppcheck with --inline-suppr) with the ids taken form xml output, but it does not work for me.
blz
2010-06-02 11:08:39
@btz I hadn't notice that - just tested it, and you are right - it doesn't work.
anon
2010-06-02 11:17:57
Hello, just tested it with the latest cppcheck version 1.44 and it works like a charm. Things you have to remember when using cppcheck-suppress:1. put "//cppcheck-suppress <id>" in a new line before the line in which error to be suppressed occurrs.2. provide the correct, full paths to cppcheck (I used wrong one with /home/mycode/other_dir/../test.cpp)3. Enjoy warning/problems free cppcheck reports :-)Thanks a lot Neil.
blz
2010-08-10 07:33:39