Search code examples
c++cppcheck

Multiline supression with cppcheck


I would like to use multiline suppression in cppcheck. Is that possible? For example: I would like to change

// cppcheck-suppress unusedFunction
int fn1(){
    return 42;
}
// cppcheck-suppress unusedFunction
int fn2(){
}
// cppcheck-suppress unusedFunction
int fn3(){
}
int main(){
}

to something like:

// cppcheck-suppress-start unusedFunction
int fn1(){
    return 42;
}
int fn2(){
}
int fn3(){
}
// cppcheck-suppress-end unusedFunction
int main(){
}

Solution

  • No; per the manual, inline suppressions have no "begin"/"end" equivalent syntax.

    However, there are other ways to set suppressions; if you wanted to use unusedFunction throughout a whole source file, for example, you can say that in a suppressions file.

    Refer to chapter 6 in the above linked manual.