Cppcheck: how to skip a directory of third-party header files?

I call cppcheck in our own files in our source database. However, some source files include header files from third-party libraries, such as from ./lib/some_library/ . They are also automatically analyzed by cppcheck.

I do not want this, since I do not want to see warnings about third-party code. Is there any way around this?

The difference with how I can say that cppcheck skips the header file is that this post explicitly asks to skip the entire directory, not just a separate header file.

+7
cppcheck
source share
2 answers

According to cppcheck's manual :: https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwiQi9bV6_TTAhWpjF2KF2F2F2F2FQAF2AF2F2AF2AF2AF2F2AF2F2F2F2AF2Af2f2f2ff2f2fcf2fcf2fcf2f2 .pdf & usg = AFQjCNEYSf0Cbm1L1D10t2QNJLg3Cd3EcA & sig2 = nZZiA8VUZejVBDdcRDj7ig

Excluding a file or folder during scanning To exclude a file or folder, there are two options. The first option is to provide only the paths and files you want to check.

 cppcheck src/a src/b 

Then all files in src / a and src / b are checked.

The second option is to use -i, with it you specify files / paths to ignore. This command does not scan files in src / c:

 cppcheck -isrc/c src 

This option currently does not work with the --project option and is only valid when directory input is submitted.

To ignore multiple directories, put -i several times. The following command ignores both the src / b and src / c directories.

 cppcheck -isrc/b -isrc/c 
+1
source share

Another possibility is to use suppressions through a file (see manual chapter 7 "Suppressing listing in a file") or through commandline .

Your suppressions.txt file may be

*:/path/to/your/thirdpartylibs/*

To eliminate all errors from this path. Syntax

[error id]:[filename]:[line]

with wildcard support for * (multiple characters) and ? (single character).

Then the cppcheck call will

 cppcheck --suppressions-list=suppressions.txt . 
+1
source share

All Articles