2016-12-28 15:26:07 +00:00
|
|
|
# cppcheck
|
|
|
|
|
|
|
|
> A static analysis tool for C/C++ code.
|
|
|
|
> Instead of syntax errors, it focuses on the types of bugs that compilers normally do not detect.
|
2019-06-09 00:05:29 +01:00
|
|
|
> More information: <http://cppcheck.sourceforge.net>.
|
2016-12-28 15:26:07 +00:00
|
|
|
|
2019-02-11 18:00:49 +00:00
|
|
|
- Recursively check the current directory, showing progress on the screen and logging error messages to a file:
|
2016-12-28 15:26:07 +00:00
|
|
|
|
|
|
|
`cppcheck . 2> cppcheck.log`
|
|
|
|
|
2019-02-11 18:00:49 +00:00
|
|
|
- Recursively check a given directory, and don't print progress messages:
|
2016-12-28 15:26:07 +00:00
|
|
|
|
2019-02-11 18:00:49 +00:00
|
|
|
`cppcheck --quiet {{path/to/directory}}`
|
2016-12-28 15:26:07 +00:00
|
|
|
|
|
|
|
- Check a given file, specifying which tests to perform (by default only errors are shown):
|
|
|
|
|
|
|
|
`cppcheck --enable={{error|warning|style|performance|portability|information|all}} {{path/to/file.cpp}}`
|
|
|
|
|
2019-04-22 13:44:54 +01:00
|
|
|
- List available tests:
|
2016-12-28 15:26:07 +00:00
|
|
|
|
2019-04-22 13:44:54 +01:00
|
|
|
`cppcheck --errorlist`
|
2016-12-28 15:26:07 +00:00
|
|
|
|
|
|
|
- Check a given file, ignoring specific tests:
|
|
|
|
|
|
|
|
`cppcheck --suppress={{test_id1}} --suppress={{test_id2}} {{path/to/file.cpp}}`
|
|
|
|
|
2019-02-11 18:00:49 +00:00
|
|
|
- Check the current directory, providing paths for include files located outside it (e.g. external libraries):
|
2016-12-28 15:26:07 +00:00
|
|
|
|
2019-02-11 18:00:49 +00:00
|
|
|
`cppcheck -I {{include/directory_1}} -I {{include/directory_2}} .`
|
2016-12-28 15:26:07 +00:00
|
|
|
|
|
|
|
- Check a Microsoft Visual Studio project (`*.vcxproj`) or solution (`*.sln`):
|
|
|
|
|
|
|
|
`cppcheck --project={{path/to/project.sln}}`
|