Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1837,9 +1837,13 @@ void CmdLineParser::printHelp(bool premium) const
" this is not needed.\n"
" --include=<file>\n"
" Force inclusion of a file before the checked file.\n"
" -i <str> Exclude source files or directories matching str from\n"
" the check. This applies only to source files so header\n"
" files included by source files are not matched.\n"
" -i <str> Ignore files that match <str>. <str> can be a filename\n"
" or directory and can contain *,**,?. A file that is\n"
" ignored will not be checked directly (the whole\n"
" translation unit is skipped completely). Header files\n"
" are checked indirectly when they are #include'd.\n"
" Note: If you want to prevent warnings in some headers,\n"
" use suppressions instead.\n"
" --inconclusive Allow that Cppcheck reports even though the analysis is\n"
" inconclusive.\n"
" There are false positives with this option. Each result\n"
Expand Down
8 changes: 4 additions & 4 deletions man/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ Typically a `compile_commands.json` contains absolute paths. However no matter i
* a file with relative path `src/test2.c` can be checked.
* a file with relative path `src/test3.cpp` is not checked.

### Excluding a file or folder from checking
### Ignore files matching a given pattern

The option `-i` specifies a pattern to files/folders to exclude. With this command no files in `src/c` are checked:
With `-i <str>` you can configure filename/directory patterns that should be ignored.

cppcheck -isrc/c src
A file that is ignored will not be checked directly (the complete translation unit is skipped). Any header #include'd from a source file which is not ignored is checked indirectly, regardless if the header is ignored.

The `-i` option is not used during preprocessing, it can't be used to exclude headers that are included.
> *Note*: If you want to filter out warnings for a header file then `-i` will not work. Use suppressions instead.

You can use `**`, `*` and `?` in the pattern to specify excluded folders/files.
`**`: matches zero or more characters, including path separators
Expand Down
Loading