CPPCHECK(1)
π CPPCHECK(1) β the cppcheck user manual, but make it make sense π
okay bestie, so this is the cppcheck manual page β it's from the cppcheck User Manual section of the man pages, and it's genuinely a lot, so we're doing this in parts. buckle up, hydrate, and let's get into it π«Ά
β¨ NAME β¨
cppcheck β the tool for static C/C++ code analysis. that's it, that's the whole vibe. it reads your code and side-eyes it before your compiler even gets a chance π
β¨ SYNOPSIS β¨
like, here's the whole shape of how you call it. don't panic at the wall of flags, we're gonna get to every single one:
cppcheck [--check-config] [--check-library] [-D<id>] [-U<id>]
[--disable=<id>] [--enable=<id>] [--error-exitcode=<n>]
[--errorlist] [--exitcode-suppress=<spec>]
[--exitcode-suppressions=<file>] [--file-list=<file>]
[--filesdir] [--force] [--fsigned-char] [--funsigned-char]
[--help] [-I<dir>] [--includes-file=<file>]
[--config-exclude=<dir>] [--config-excludes-file=<file>]
[--include=<file>] [-i<dir>] [--inconclusive] [--inline-suppr]
[-j<jobs>] [-l<load>] [--language=<language>] [--library=<cfg>]
[--max-configs=<limit>] [--max-ctu-depth=<limit>]
[--platform=<type>] [--quiet] [--relative-paths=<paths>]
[--report-progress] [--report-type=<type>] [--rule=<rule>]
[--rule-file=<file>] [--showtime=<mode>] [--std=<id>]
[--suppress=<spec>] [--suppressions-list=<file>]
[--suppress-xml=<.xml file>] [--template='<text>'] [--verbose]
[--version] [--xml] [--xml-version=<version>]] [file or path]
...
and yeah, that ending is fr fr just [file or path] followed by ... β meaning you can yeet as many files or paths at it as you want π
β¨ DESCRIPTION β¨
okay so cppcheck is a command-line tool whose entire main character job is trying to detect bugs that your C/C++ compiler doesn't see. like, your compiler already did its thing and clocked out, and cppcheck is over here finding the stuff it missed. π₯
it's versatile β no cap β and it can check non-standard code, including:
- various compiler extensions
- inline assembly code
- etc. (yes, the manpage literally says "etc.", iconic)
its internal preprocessor can handle includes, macros, and several preprocessor commands. so it's not just skimming your files, it's actually processing them properly π§
and here's the bestie part: while cppcheck is highly configurable (like, extremely, you'll see), you can literally just start using it by giving it a path to your source code. that's the whole entry requirement. no config file, no setup arc, just point and go β¨
ngl the "just give it a path" part is the moment this tool ate and left no crumbs β everything else is optional seasoning π
(more coming in part 2, don't go anywhere bestie π)
β¨ OPTIONS β¨
Analyze given C/C++ files for common errors. That's the whole vibe of this bad boy π
-CCβ Do not remove comments during preprocessing (requires-E). Yes, that's two C's, bestie, not a typo π«Ά--check-configβ Check Cppcheck configuration. The normal code analysis is disabled by this flag. So like, it's just doing a lil vibe check on the config and nothing else β¨--check-libraryβ Show information messages when library files have incomplete info. Very "hey queen, your library's missing a few brain cells" energy π-D<id>β By default Cppcheck checks all configurations. Use-Dto limit the checking. When-Dis used the checking is limited to the given configuration. Example:-DDEBUG=1 -D__cplusplus. So you're basically telling it "only look here, bestie" π-U<id>β By default Cppcheck checks all configurations. Use'-U'to explicitly hide certain#ifdef <id>code paths from checking. Example:'-UDEBUG'. It's giving "nothing to see here, move along" π-Eβ Print preprocessor output on stdout and don't do any further processing. Just the preprocessor, no thoughts, head empty πΈ--disable=<id>β Disable individual checks. Please refer to the documentation of--enable=<id>for further details. (Spoiler: it's literally the next option, keep scrolling π)--enable=<id>β Enable additional checks. The available ids are:allβ Enable all checks. It is recommended to only use--enable=allwhen the whole program is scanned, because this enablesunusedFunction. Main character energy, but like, it needs the whole squad present πwarningβ Enable warning messagesstyleβ Enable all coding style checks. All messages with the severities 'style', 'performance' and 'portability' are enabled.performanceβ Enable performance messagesportabilityβ Enable portability messagesinformationβ Enable information messagesunusedFunctionβ Check for unused functions. It is recommend to only enable this when the whole program is scanned. (Yes it says "recommend", we're keeping it fr)missingIncludeβ Warn if there are missing includes
By default none of the additional checks are enabled. Several ids can be given if you separate them with commas, e.g. --enable=style,unusedFunction. See also --std. Commas are the moment, ok? π
--error-exitcode=<n>β If errors are found, integer <n> is returned instead of default0.EXIT_FAILUREis returned if arguments are not valid or if no input files are provided. Note that your operating system can modify this value, e.g.256can become0. Likeβ¦ rude of the OS but okay π--errorlistβ Print a list of all possible error messages in XML format. The full menu of everything that could ever go wrong, iconic β¨--exitcode-suppress=<spec>β Used to specify an error ID which should not result in a non-zero exitcode.--exitcode-suppressions=<file>β Used when certain messages should be displayed but should not cause a non-zero exitcode. So it still shows up, it just doesn't throw hands at your exit code π--file-list=<file>β Specify the files to check in a text file. One filename per line. When file is-, the file list will be read from standard input. Stdin girlies rise up π§--filesdirβ Print the built-inFILESDIR. That's it. That's the whole job π¦-f,--forceβ Force checking of files that have a lot of configurations. Error is printed if such a file is found so there is no reason to use this by default. If used together with--max-configs=, the last option is the one that is effective. Last one wins, periodt β--fsigned-charβ Treatchartype as signed. This overrides previous--platformoptions and is overridden by following ones. Order matters, babes π--funsigned-charβ Treatchartype as unsigned. This overrides previous--platformoptions and is overridden by following ones. Same deal, opposite vibes π₯-h,--helpβ Print help text. When in doubt, ask for help π-I <dir>β Give path to search for include files. Give several-Iparameters to give several paths. First given path is searched for contained header files first. If paths are relative to source files, this is not needed. First come, first searched, no cap π--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.--config-exclude=<dir>β Path (prefix) to be excluded from configuration checking. Preprocessor configurations defined in headers (but not sources) matching the prefix will not be considered for evaluation of configuration alternatives. So it's a little VIP velvet rope for configs π«Ά--config-exclude-file=<file>β A file that contains a list of config-excludes. Bulk velvet rope, we love to see it π--include=<file>β Force inclusion of a file before the checked file. Can be used for example when checking the Linux kernel, whereautoconf.hneeds to be included for every file compiled. Works the same way as the GCC-includeoption. Very "you WILL meet my friend first" energy π€-i <dir>β Give path to ignore. Give several-iparameters to ignore several paths. Give directory name or filename with path as parameter. Directory name is matched to all parts of the path. Ignore list behavior, we stan π«--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 is good or bad. Lowkey risky bestie β receipts must be checked before you fight π--inline-supprβ Enable inline suppressions. Use them by placing comments in the form:// cppcheck-suppress memleakbefore the line to suppress. A little note-to-self in your code, adorable π-j <jobs>β Start <jobs> threads to do the checking work. Multithreaded queen behavior π-l <load>β Specifies that no new threads should be started if there are other threads running and the load average is at least <load> (ignored on non UNIX-like systems). It's giving "read the room" before spawning more threads π--language=<language>β Forces cppcheck to check all files as the given language. Valid values are:c,c++. Commit to a personality, bestie β¨--library=<cfg>β Use library configuration.--max-configs=<limit>β Maximum number of configurations to check in a file before skipping it. Default is12. If used together with--force, the last option is the one that is effective. Twelve's the limit, then we move on πββοΈ--max-ctu-depth=<limit>β Maximum depth in whole program analysis. Default is2. How deep do we go? Two. Two deep. π--platform=<type>β Specifies platform specific types and sizes. The available platforms are:unix32β 32 bit unix variantunix64β 64 bit unix variantwin32Aβ 32 bit Windows ASCII character encodingwin32Wβ 32 bit Windows UNICODE character encodingwin64β 64 bit Windows
By default the platform which was used to compile Cppcheck is used. So it just matches the energy of wherever it was built πΈ
-q,--quietβ Only print something when there is an error. Silent treatment unless something's actually wrong, we love a low-drama icon π€«-rp,-rp=<paths>,--relative-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. E.g. if given value istest, when checkingtest/test.cpp, the path in output will betest.cppinstead oftest/test.cpp. The feature uses 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 to files that are on a lower level in the directory tree. Tilde girlies I'm so sorry, it's literally string comparison π--report-progressβ Report progress when checking a file. Live updates, we're locked in π¬--report-type=<type>β Add guideline and classification fields for specified coding standard. The available report types are:normalβ Default, only show cppcheck error ID and severity)autosarβ Autosarcert-c-2016β Cert C 2016cert-cpp-2016β Cert C++ 2016misra-c-2012β Misra C 2012misra-c-2023β Misra C 2023misra-c-2025β Misra C 2025misra-cpp-2008β Misra C++ 2008misra-cpp-2023β Misra C++ 2023
(And yeah, that stray ) on normal is in the original, we're keeping it exactly, no cap π
)
--rule=<rule>β Match regular expression to create your own checks. E.g. rule"/ 0"can be used to check division by zero. This command is only available if cppcheck was compiled withHAVE_RULES=yes. DIY checks, main character energy β¨--rule-file=<file>β Use given rule XML file. See https://sourceforge.net/projects/cppcheck/files/Articles/ for more info about the syntax. This command is only available if cppcheck was compiled withHAVE_RULES=yes. SameHAVE_RULES=yescaveat, don't come for me π«Ά--showtime=<mode>β Show timing information. The available mode are:noneβ Show nothing (default)fileβ Show for each processed filefile-totalβ Show total time only for each processed filefile-totalβ¦ ok wait, that'sfile-total. Next:summaryβ Show a summary at the endtop5_fileβ Show the top 5 for each processed filetop5_summaryβ Show the top 5 summary at the end
(Yep, "the available mode are" β original grammar, we keep it π)
--std=<id>β Set standard. The available options are:c89β C code is C89 compatiblec99β C code is C99 compatiblec11β C code is C11 compatible (default)c++03β C++ code is C++03 compatiblec++11β C++ code is C++11 compatiblec++14β C++ code is C++14 compatiblec++17β C++ code is C++17 compatiblec++20β C++ code is C++20 compatible (default)
Two defaults, one for C and one for C++, we contain multitudes π
--suppress=<spec>β Suppress a specific warning. The format of <spec> is:[error id]:[filename]:[line]. The[filename]and[line]are optional.[error id]may be*to suppress all warnings (for a specified file or files).[filename]may contain the wildcard characters*or?. Wildcards in the filename, we're flexible like that π¦--suppressions-list=<file>β Suppress warnings listed in the file. Each suppression is in the format of <spec> above. Same spec, just in a file, iconique π--suppress-xml=<.xml file>β Use suppressions defined in xml as described in the manual. XML girlies, this one's for you π--template='<text>'β Format the error messages. E.g.'{file}:{line},{severity},{id},{message}'or'{file}({line}):({severity}) {message}'. Pre-defined templates:gcc,vs. Make it look however you want, it's your world β-v,--verboseβ More detailed error reports. The tea is PIPING hot and fully explained β--versionβ Print out version information. Who are you? What's your number? π--xmlβ Write results in XML to error stream. Structured chaos, but make it XML πΈ--xml-version=<version>β Select the XML file version. Also implies--xml. Currently only version2is available. The default version is2. One version to rule them all π
π AUTHOR π
The program was written by Daniel MarjamΓ€ki and Cppcheck team. See AUTHORS file for list of team members. Shoutout to the whole squad, fr fr π«Ά
π¦ SEE ALSO π¦
Full list of features: https://sourceforge.net/p/cppcheck/wiki/Home/ β go read it, it's giving lore π
π AUTHOR π
- Reijo Tomperi
<aggro80@users.sourceforge.net>β Wrote this manpage for the Debian system. The original manpage author, absolute legend, we thank them for their service π
π COPYRIGHT π
okay so legal stuff time, bestie, but it's actually kinda cute because it's a gift economy moment π
- Copyright Β© 2009 - 2016 Reijo Tomperi β like, the whole thing is his, periodt π
- This manual page was written for the Debian system (but may be used by others) β so it's a Debian girlie first and foremost, but she's not gatekeeping, anyone can borrow her π«Ά
- Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 3 or (at your option) any later version published by the Free Software Foundation. so yeah, remix it, share it, whatever, just keep it under the GPL vibe π
- On Debian systems, the complete text of the GNU General Public License can be found in
/usr/share/common-licenses/GPL-3β that's the whole lore, go read it if you're the type who reads the terms (iconic behavior honestly) π
and that's a wrap on the whole cppcheck page, bestie!! π
you now know every flag, every default, every exit code, and every little caveat. go forth and lint. no cap, you're gonna slay it β¨π¦
β§ο½₯οΎ: * this page ships as cppcheck, dated 09/20/2026, and files itself under CPPCHECK(1) β she's iconic, she's documented, she's legally licensed, iykyk π π β§ο½₯οΎ:
π¦ where this page comes from
- arch rolling: cppcheck 2.22.0-1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms