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

I call cppcheck on our own files in our source base. However, some source files include header files from third party libraries, say from ./lib/some_library/ . These are automatically parsed by cppcheck as well.

I don't want this, since I don't want to see warnings on third party code. Is there a way to get around this?

The difference with how can i tell cppcheck to skip a header file is that this post explicitly asks for skipping an entire directory, not just an individual header file.


Another possibility would be to use suppressions via a file (see manual chapter 7 "Listing suppressions in a file") or via commandline.

Your suppressions.txt could be

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

Which would exclude all errors from that path. The syntax is

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

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

The call to cppcheck would then be

cppcheck --suppressions-list=suppressions.txt .

As per cppcheck manual :: https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwiQi9bV6_TTAhWpjFQKHeroAw4QFggnMAA&url=http%3A%2F%2Fcppcheck.sourceforge.net%2Fmanual.pdf&usg=AFQjCNEYSf0Cbm1L1D10t2QNJLg3Cd3EcA&sig2=nZZiA8VUZejVBDdcRDj7ig

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

cppcheck src/a src/b

All files under src/a and src/b are then checked.

The second option is to use -i, with it you specify files/paths to ignore. With this command no files in src/c are checked:

cppcheck -isrc/c src

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

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

cppcheck -isrc/b -isrc/c
链接地址: http://www.djcxy.com/p/34528.html

上一篇: 如何将标题添加到轮廓图上的颜色键?

下一篇: Cppcheck:如何跳过第三方头文件的目录?