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

Chiel ten Brinke picture Chiel ten Brinke · Jun 3, 2016 · Viewed 12.4k times · Source

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.

Answer

Prashant Nidgunde picture Prashant Nidgunde · May 16, 2017

As per cppcheck manual:

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