Search code examples
cppcheck

Cppcheck inline suppression not working


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?


Solution

  • This way:

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

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