From 9bae189d9e3037d0ffb42aa962c13c9166632fc2 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Wed, 9 Sep 2015 15:23:42 +0200 Subject: [PATCH] Added description of -I to manual, improved formatting. --- man/manual.docbook | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/man/manual.docbook b/man/manual.docbook index 378ad95a2..f67a1ec56 100644 --- a/man/manual.docbook +++ b/man/manual.docbook @@ -5,15 +5,15 @@ Cppcheck 1.71 dev - 2015-06-20 + 2015-09-09 Introduction Cppcheck is an analysis tool for C/C++ code. Unlike C/C++ compilers - and many other analysis tools, it doesn't detect syntax errors. Cppcheck - only detects the types of bugs that the compilers normally fail to detect. + and many other analysis tools, it doesn't detect syntax errors. Instead, Cppcheck + detects the types of bugs that the compilers normally fail to detect. The goal is no false positives. Supported code and platforms: @@ -35,8 +35,6 @@ - Accuracy - Please understand that there are limits of Cppcheck. Cppcheck is rarely wrong about reported errors. But there are many bugs that it doesn't detect. @@ -82,7 +80,7 @@ cppcheck path - If "path" is a folder then cppcheck will check all source files in + If "path" is a folder then cppcheck will recursively check all source files in this folder. Checking path/file1.cpp... @@ -94,10 +92,8 @@ Checking path/file2.cpp...
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. + 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 @@ -112,6 +108,23 @@ Checking path/file2.cpp... cppcheck -isrc/c src
+
+ Include paths + + To add an include path, use -I, followed by the path. + + Cppcheck's preprocessor basically handles includes like any other preprocessor. + However, while other preprocessors stop working when they encounter a missing header, + cppcheck will just print an information message and continues parsing the code. + + The purpose of this behaviour is that cppcheck is meant to work without + necessarily seeing the entire code. Actually, it is recommended to not give all include + paths. While it is useful for cppcheck to see the declaration of a class when checking the + implementation of its members, passing standard library headers is highly discouraged because + it will result in worse results and longer checking time. For such cases, .cfg files (see below) are the + better way to provide information about the implementation of functions and types to cppcheck. +
+
Severities @@ -208,7 +221,7 @@ cppcheck --enable=unusedFunction file.c cppcheck --enable=all Please note that --enable=unusedFunction should - only be used when the whole program is scanned. And therefore + only be used when the whole program is scanned. Therefore, --enable=all should also only be used when the whole program is scanned. The reason is that the unusedFunction checking will warn if a function is not called. There will be noise if function calls @@ -248,6 +261,8 @@ cppcheck --enable=all folder: cppcheck -j 4 path + + Please note that this will disable unusedFunction checking.
@@ -284,13 +299,13 @@ cppcheck -DA --force file.c XML output - Cppcheck can generate the output in XML format. + Cppcheck can generate output in XML format. There is an old XML format (version 1) and a new XML format (version 2). Please use the new version if you can. The old version is kept for backwards compatibility only. It will - not be changed. But it will likely be removed someday. Use + not be changed, but it will likely be removed someday. Use --xml to enable this format. The new version fixes a few problems with the old format. The new @@ -298,8 +313,9 @@ cppcheck -DA --force file.c attributes and elements. A sample command to check a file and output errors in the new XML format: - cppcheck --xml-version=2 file1.cppHere - is a sample version 2 report: + cppcheck --xml-version=2 file1.cpp + + Here is a sample version 2 report: <?xml version="1.0" encoding="UTF-8"?> <results version="2">