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?
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.
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:
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.
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.
This way:
class Foo {
// cppcheck-suppress noExplicitConstructor
Foo(int foo) { }
};
It requires --inline-suppr
as command line argument.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With