Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cppcheck inline suppression not working

Tags:

cppcheck

Example code:

class Foo {
    // cppcheck-suppress noExplicitConstructor
    Foo(int foo) { }
}

Cppcheck call:

$ cppcheck.exe --enable=all foo.cpp
Checking foo.cpp...
[foo.cpp:3]: (style) Class 'Foo' has a constructor with 1 argument that is not explicit.

How can I suppress this error?

like image 969
chtenb Avatar asked Jun 08 '16 11:06

chtenb


People also ask

How to prevent Cppcheck from failing where other static debugger succeed?

This is an example where cppcheck fails where other static debugger succeed. ####Inline Suppression One way to prevent a certain error is by using inline suppression. By following the format of cppcheck-suppress <ERROR:ID>, cppcheck will recognize this, and will not print out the error.

How do I suppress an error in Cppcheck?

If you don't know what the error is called when you want to suppress it, you can run the command cppcheck --xml <FILENAME> . Look for "error id = " for the id of the error. Following the same format as the example, you can suppress that specific error. The following is an example on the usage of inline suppression:

How to check files manually with Cppcheck?

With Cppcheck you can check files manually by specifying files/paths to check and settings. Or you can use a build environment, such as CMake or Visual Studio. We don’t know which approach (project file or manual configuration) will give you the best results.

What are the problems with Cppcheck?

Cppcheck then fails to detect various problems such as memory leaks, buffer overflows, possible null pointer dereferences, etc. But this can be fixed with configuration files.


1 Answers

This way:

class Foo {     
// cppcheck-suppress  noExplicitConstructor     
 Foo(int foo) { } 
}; 

It requires --inline-suppr as command line argument.

like image 70
orbitcowboy Avatar answered Sep 30 '22 11:09

orbitcowboy