漢字均為翻譯 以下翻譯均采用谷歌翻譯
Syntax: 語法
cppcheck [OPTIONS] [files or paths]If a directory is given instead of a filename, *.cpp, *.cxx, *.cc, *.c++, *.c,*.tpp, and *.txx files are checked recursively from the given directory.如果給出目錄而不是文件名* .cpp,*。cxx,* .cc,* .c ++,* .c,* .tpp和* .txx文件從給定目錄遞歸檢查。Options: --cppcheck-build-dir=<dir> Analysis output directory. Useful for various data. Some possible usages are; whole PRogram analysis,incremental analysis, distributed analysis.
分析輸出目錄。 有用的各種數據。 一些可能的用法是: 整個程序分析, 增量分析,分布式分析。
--check-config Check cppcheck configuration. The normal codeanalysis is disabled by this flag.
檢查cppcheck配置。 正常代碼 分析由此標志禁用
--check-library Show information messages when library files haveincomplete info.
庫文件具有時顯示信息消息 不完整的信息。
--config-exclude=<dir> Path (prefix) to be excluded from configuration checking. Preprocessor configurations defined in headers (but not sources) matching the prefix will notbe considered for evaluation.
要從配置中排除的路徑(前綴) 檢查。 在中定義的預處理器配置 匹配前綴的頭(但不是源)不會 被考慮進行評價。
--config-excludes-file=<file>A file that contains a list of config-excludes
包含配置排除的列表的文件
--dump Dump xml data for each translation unit. The dump files have the extension .dump and contain ast,tokenlist, symboldatabase, valueflow.
轉儲每個翻譯單元的xml數據。 轉儲 文件具有擴展名.dump并包含ast, tokenlist,symboldatabase,valueflow。
-D<ID> Define preprocessor symbol. Unless --max-configs or --force is used, Cppcheck will only check the given configuration when -D is used.Example: '-DDEBUG=1 -D__cplusplus'.
定義預處理器符號。 除非--max-configs或 --force被使用,Cppcheck只會檢查給定 配置時使用-D。 示例:'-DDEBUG = 1 -D__cplusplus'。
-U<ID> Undefine preprocessor symbol. Use -U to explicitly hide certain #ifdef <ID> code paths from checking.Example: '-UDEBUG'
未定義預處理器符號。 使用-U顯式 從檢查中隱藏某些#ifdef <ID>代碼路徑。 示例:'-UDEBUG'
-E Print preprocessor output on stdout and don't do anyfurther processing.
在stdout上打印預處理器輸出,不做任何操作 進一步處理。
--enable=<id> Enable additional checks. The available ids are:
啟用其他檢查。 可用的ID是:
* all Enable all checks. It is recommended to only use --enable=all when the whole program isscanned, because this enables unusedFunction.
啟用所有檢查。 建議只有 使用--enable = all當整個程序是 掃描,因為這啟用unusedFunction。
* warningEnable warning messages
啟用警告消息
* style Enable all coding style checks. All messages with the severities 'style', 'performance' and'portability' are enabled.
啟用所有編碼風格檢查。 所有消息 具有嚴重的風格,性能和 '可移植性'。
* performanceEnable performance messages
啟用性能消息
* portability 可移植性Enable portability messages
啟用可移植性消息
* informationEnable information messages
啟用信息消息
* unusedFunction Check for unused functions. It is recommend to only enable this when the whole program isscanned.
檢查未使用的功能。 這是推薦 只有當整個程序是啟用這個 掃描。
* missingInclude Warn if there are missing includes. For detailed information, use '--check-config'. Several ids can be given if you separate them withcommas. See also --std
如果有缺失包括警告。 對于 詳細信息,請使用“--check-config”。 如果您將它們分開,可以給出幾個ids 逗號。 另請參見--std
--error-exitcode=<n> If errors are found, integer [n] is returned instead of the default '0'. '1' is returned if arguments are not valid or if no input files are provided. Note that your Operating system can modifythis value, e.g. '256' can become '0'.
如果發現錯誤,則返回integer [n],而不是返回 默認為'0'。 返回'1' 如果參數無效或沒有輸入文件 提供。 注意,您的操作系統可以修改 這個值,例如。 '256'可以變為'0'。
--errorlist Print a list of all the error messages in XML format.
以XML格式打印所有錯誤消息的列表。
--doc Print a list of all available checks.
打印所有可用檢查的列表。
--exitcode-suppressions=<file> Used when certain messages should be displayed butshould not cause a non-zero exitcode.
在應顯示某些消息時使用 不應該導致非零退出代碼。
--file-list=<file> Specify the files to check in a text file. Add one filename per line. When file is '-,' the file list willbe read from standard input.
指定要在文本文件中檢查的文件。 添加一個 filename每行。 當文件是 - 時,文件列表將 從標準輸入讀取。
-f, --force Force checking of all configurations in files. If used together with '--max-configs=', the last option is theone that is effective.
強制檢查文件中的所有配置。 如果使用 加上'--max-configs =',最后一個選項是 一個是有效的。
-h, --help Print this help. -I <dir> Give path to search for include files. Give several -I parameters to give several paths. First given path is searched for contained header files first. If paths arerelative to source files, this is not needed.
指定搜索包含文件的路徑。 給幾個-I 參數給出幾個路徑。 首先給定的路徑是 首先搜索包含的頭文件。 如果路徑 相對于源文件,這不是必需的。
--includes-file=<file> Specify directory paths to search for included header files in a text file. Add one include path per line. First given path is searched for contained header files first. If paths are relative to source files,this is not needed.
指定搜索包含的標題的目錄路徑 文件在文本文件中。 每行添加一個包含路徑。 首先給定的路徑搜索包含的頭 文件。 如果路徑相對于源文件, 這不是必需的。
--include=<file> Force inclusion of a file before the checked file. Can be used for example when checking the linux kernel, where autoconf.h needs to be included for every file compiled. Works the same way as the GCC -includeoption.
強制在選中文件之前包含文件。 能夠 例如在檢查Linux內核時, 其中每個文件都需要包含autoconf.h 編譯。 工作方式與GCC相同 - 包括 選項。
-i <dir or file> Give a source file or source file directory to exclude from the check. This applies only to source files so header files included by source files are not matched.Directory name is matched to all parts of the path.
給出要排除的源文件或源文件目錄 從檢查。 這僅適用于源文件等 源文件包括的頭文件不匹配。 目錄名稱與路徑的所有部分匹配。
--inconclusive Allow that Cppcheck reports even though the analysis is inconclusive. There are false positives with this option. Each result must be carefully investigated before you know if it isgood or bad.
即使分析是,仍允許Cppcheck報告 不確定。 這個選項有假陽性。 每個結果 必須仔細調查,才知道是否 是好是壞。
--inline-suppr Enable inline suppressions. Use them by placing one or more comments, like: '// cppcheck-suppress warningId'on the lines before the warning to suppress.
啟用內聯抑制。 通過放置一個或使用它們 更多評論,如:'// cppcheck-suppress warningId' 在線前警告壓制。
-j <jobs> Start <jobs> threads to do the checking simultaneously.
啟動<jobs>線程以同時進行檢查。
--language=<language>, -x <language> Forces cppcheck to check all files as the givenlanguage. Valid values are: c, c++
強制cppcheck檢查所有文件作為給定 語言。 有效值為:c,c ++
--library=<cfg> Load file <cfg> that contains information about types and functions. With such information Cppcheck understands your your code better and therefore you get better results. The std.cfg file that is distributed with Cppcheck is loaded automatically. For more information about library files, read themanual.
加載包含類型信息的文件<cfg> 和功能。 有這樣的信息Cppcheck 理解你的代碼更好,因此你 獲得更好的效果。 std.cfg文件是 分發與Cppcheck自動加載。 有關庫文件的詳細信息,請閱讀 手冊。
--project=<file> Run Cppcheck on project. The <file> can be a Visual Studio Solution (*.sln), Visual Studio Project (*.vcxproj), or compile database (compile_commands.json). The files to analyse, include paths, defines, platform and undefines inthe specified file will be used.
在項目上運行Cppcheck。 <file>可以是Visual Studio解決方案(* .sln),Visual Studio項目 (* .vcxproj),或編譯數據庫 (compile_commands.json)。 要分析的文件, 包括路徑,定義,平臺和未定義 將使用指定的文件。
--max-configs=<limit> Maximum number of configurations to check in a file before skipping it. Default is '12'. If used together with '--force', the last option is the one that iseffective.
要在文件中檢查的最大配置數 跳過它之前。 默認值為“12”。 如果一起使用 與“--force”,最后一個選項是一個 有效。
--platform=<type>, --platform=<file> Specifies platform specific types and sizes. The available builtin platforms are: * unix32 32 bit unix variant * unix64 64 bit unix variant * win32A 32 bit Windows ASCII character encoding * win32W 32 bit Windows UNICODE character encoding * win64 64 bit Windows * native Unspecified platform. Type sizes of host systemare assumed, but no further assumptions.
指定平臺特定類型和大小。 的 可用的內置平臺有: * unix32 32位unix變體 * unix64 64位unix變體 * win32A 32位Windows ASCII字符編碼 * win32W 32位Windows UNICODE字符編碼 * win64 64位Windows *本機 未指定的平臺。 鍵入主機系統的大小 假設,但沒有進一步的假設。
-q, --quiet Do not show progress reports.
不顯示進度報告。
-rp, --relative-paths -rp=<paths>, --relative-paths=<paths> Use relative paths in output. When given, <paths> are used as base. You can separate multiple paths by ';'. Otherwise path where source files are searched is used. We use string comparison to create relative paths, so using e.g. ~ for home folder does not work. It is currently only possible to apply the base paths tofiles that are on a lower level in the directory tree.
在輸出中使用相對路徑。 當給定時,<路徑>是 用作基礎。 您可以通過';'分隔多個路徑。 否則使用搜索源文件的路徑。 我們使用字符串比較創建相對路徑,所以 使用。 ?為home文件夾不工作。 它是 目前只能應用基本路徑 目錄樹中較低級別的文件。
--report-progress Report progress messages while checking a file.
檢查文件時報告進度消息。
--rule=<rule> Match regular expression.
匹配正則表達式。
--rule-file=<file> Use given rule file. For more information, see:http://sourceforge.net/projects/cppcheck/files/Articles/
使用給定的規則文件。 有關詳細信息,請參閱: http://sourceforge.net/projects/cppcheck/files/Articles/
--std=<id> Set standard. The available options are: * posix POSIX compatible code * c89 C code is C89 compatible * c99 C code is C99 compatible * c11 C code is C11 compatible (default) * c++03 C++ code is C++03 compatible * c++11 C++ code is C++11 compatible (default) More than one --std can be used:'cppcheck --std=c99 --std=posix file.c'
設置標準。 可用的選項有: * posix POSIX兼容代碼 * c89 C代碼與C89兼容 * c99 C代碼與C99兼容 * c11 C代碼是C11兼容(默認) * c ++ 03 C ++代碼與C ++ 03兼容 * c ++ 11 C ++代碼是C ++ 11兼容(默認) 可以使用多個--std: 'cppcheck --std = c99 --std = posix file.c'
--suppress=<spec> Suppress warnings that match <spec>. The format of <spec> is: [error id]:[filename]:[line] The [filename] and [line] are optional. If [error id]is a wildcard '*', all error ids match.
禁止符合<spec>的警告。 格式為 <spec>是: [error id]:[filename]:[line] [filename]和[line]是可選的。 如果[錯誤id] 是通配符“*”,所有錯誤ID都匹配。
--suppressions-list=<file> Suppress warnings listed in the file. Each suppressionis in the same format as <spec> above.
抑制文件中列出的警告。 每次抑制 與上述<spec>格式相同。
--template='<text>' Format the error messages. E.g. '{file}:{line},{severity},{id},{message}' or '{file}({line}):({severity}) {message}' or '{callstack} {message}'Pre-defined templates: gcc, vs, edit.
格式化錯誤消息。 例如。 '{file}:{line},{severity},{id},{message}'或 '{file}({line}):({severity}){message}'或 '{callstack} {message}' 預定義模板:gcc,vs,編輯。
-v, --verbose Output more detailed error information.
輸出更詳細的錯誤信息。
--version Print out version number.--xml Write results in xml format to error stream (stderr).
將結果以xml格式寫入錯誤流(stderr)。
--xml-version=<version> Select the XML file version. Currently versions 1 and2 are available. The default version is 1.
選擇XML文件版本。 目前版本1和 2可用。 默認版本為1。
Example usage: # Recursively check the current folder. Print the progress on the screen and # write errors to a file: cppcheck . 2> err.txt # Recursively check ../myproject/ and don't print progress: cppcheck --quiet ../myproject/ # Check test.cpp, enable all checks: cppcheck --enable=all --inconclusive --std=posix test.cpp # Check f.cpp and search include files from inc1/ and inc2/: cppcheck -I inc1/ -I inc2/ f.cppFor more information: http://cppcheck.net/manual.pdf新聞熱點
疑難解答