CPPLINT(1)
π CPPLINT π
okay so bestie, quick housekeeping: this is the manual page for cpplint from section 1 (User Commands), and it's literally the glow-up your C++ code has been begging for. grab a boba, we're doing this. π§β¨
π NAME π
cpplint β static code checker for C++ π¦ (yes that's the whole name section, it's short and iconic, periodt)
πΈ DESCRIPTION πΈ
okay so here's the vibe. the syntax is literally this:
cpplint.py [--verbose=#]
[--output=emacs|eclipse|vs7|junit|sed|gsed]
[--filter=-x,+y,...] [--counting=total|toplevel|detailed]
[--root=subdir] [--repository=path] [--linelength=digits]
[--headers=x,y,...] [--recursive] [--exclude=path]
[--extensions=hpp,cpp,...]
[--includeorder=default|standardcfirst] [--config=filename]
[--quiet] [--version]
<file> [file] ...
So. It's a style checker for C/C++ source files. And yes, it's a fork of the Google style checker with minor extensions β glow-up inherited from a very famous parent, we love a nepo baby that actually delivers. π
The style guidelines it's trying to follow are these ones right here:
https://google.github.io/styleguide/cppguide.html
Every single problem gets a confidence score from 1-5, where 5 means we are certain of the problem, and 1 means it could be a legitimate construct. So like, it's giving "trust me bestie" energy, not "I know all" energy. It will miss some errors, and it is not a substitute for a code review. π Fr fr. It's a helper, not your senior engineer.
π Suppressing the false positives (NOLINT lore) π
To suppress false-positive errors of certain categories, add a 'NOLINT(category[, category...])' comment to the line. NOLINT or NOLINT(*) suppresses errors of all categories on that line.
To suppress categories on the next line use NOLINTNEXTLINE instead of NOLINT.
To suppress errors in a whole block of code, drop a 'NOLINTBEGIN(category[, category...])' comment on a line at the start of the block, and to end the block add a comment with 'NOLINTEND'.
important detail alert: NOLINT blocks are inclusive, so any statements on the same line as aBEGINorENDwill have the error suppression applied. iykyk.
The files passed in will be linted; at least one file must be provided. Default linted extensions are ['c', 'c++', 'cc', 'cpp', 'cu', 'cuh', 'cxx', 'h', 'h++', 'hh', 'hpp', 'hxx']. Other file types will be ignored (sorry bestie, no .txt for you). Change the extensions with the --extensions flag.
β¨ Flags β¨
okay this is the main character section. here's every single one, no skips, no merges, no "you get the idea". π
π₯οΈ OUTPUT FORMATS π₯οΈ
--output=emacs|eclipse|vs7|junit|sed|gsedβ By default, the output is formatted to ease emacs parsing. Visual Studio compatible output (vs7) may also be used. Further support exists for eclipse (eclipse), and JUnit (junit). XML parsers such as those used in Jenkins and Bamboo may also be used. The sed format outputs sed commands that should fix some of the errors. Note that this requires gnu sed. If that is installed asgsedon your system (common e.g. on macOS with homebrew) you can use the gsed output format. Sed commands are written to stdout, not stderr, so you should be able to pipe output straight to a shell to run the fixes. π«Ά slay, piping.
π£οΈ VERBOSITY & QUIET π£οΈ
--verbose=#β Specify a number 0-5 to restrict errors to certain verbosity levels. Errors with lower verbosity levels have lower confidence and are more likely to be false positives. Ate with the honesty tbh.--quietβ Don't print anything if no errors are found. silence is golden, no notes. π€«
π FILTERING π
--filter=-x,+y,...β Specify a comma-separated list of category-filters to apply: only error messages whose category names pass the filters will be printed. (Category names are printed with the message and look like"[whitespace/indent]".) Filters are evaluated left to right."-FOO"means "do not print categories that start with FOO"."+FOO"means "do print categories that start with FOO".
Examples:
--filter=-whitespace,+whitespace/braces
--filter=-whitespace,-runtime/printf,+runtime/printf_format
--filter=-,+build/include_what_you_use
To see a list of all the categories used in cpplint, pass no arg: --filter=
Filters can directly be limited to files and also line numbers. The syntax is category:file:line , where line is optional. The filter limitation works for both + and - and can be combined with ordinary filters:
Examples:
--filter=-whitespace:foo.h,+whitespace/braces:foo.h
--filter=-whitespace,-runtime/printf:foo.h:14,+runtime/printf_format:foo.h
--filter=-,+build/include_what_you_use:foo.h:321
--counting=total|toplevel|detailedβ The total number of errors found is always printed. If'toplevel'is provided, then the count of errors in each of the top-level categories like'build'and'whitespace'will also be printed. If'detailed'is provided, then a count is provided for each category like'legal/copyright'. it's giving receipts. π§Ύ
π PATHS & HEADER GUARDS π
--repository=pathβ The top level directory of the repository, used to derive the header guard CPP variable. By default, this is determined by searching for a path that contains.git,.hg, or.svn. When this flag is specified, the given path is used instead. This option allows the header guard CPP variable to remain consistent even if members of a team have different repository root directories (such as when checking out a subdirectory with SVN). In addition, users of non-mainstream version control systems can use this flag to ensure readable header guard CPP variables.
Examples:
Assuming that Alice checks out ProjectName and Bob checks out ProjectName/trunk and trunk contains src/chrome/ui/browser.h, then with no --repository flag, the header guard CPP variable will be:
Alice => TRUNK_SRC_CHROME_BROWSER_UI_BROWSER_H_
Bob => SRC_CHROME_BROWSER_UI_BROWSER_H_
If Alice uses the --repository=trunk flag and Bob omits the flag or uses --repository=. then the header guard CPP variable will be:
Alice => SRC_CHROME_BROWSER_UI_BROWSER_H_
Bob => SRC_CHROME_BROWSER_UI_BROWSER_H_
team consistency unlocked, bestie. β¨
--root=subdirβ The root directory used for deriving header guard CPP variable. This directory is relative to the top level directory of the repository which by default is determined by searching for a directory that contains.git,.hg, or.svnbut can also be controlled with the--repositoryflag. If the specified directory does not exist, this flag is ignored.
Examples:
Assuming that src is the top level directory of the repository (and cwd=top/src), the header guard CPP variables for src/chrome/browser/ui/browser.h are:
No flag => CHROME_BROWSER_UI_BROWSER_H_
--root=chrome => BROWSER_UI_BROWSER_H_
--root=chrome/browser => UI_BROWSER_H_
--root=.. => SRC_CHROME_BROWSER_UI_BROWSER_H_
--linelength=digitsβ This is the allowed line length for the project. The default value is 80 characters. (eighty. iconic number. respect it.) π
Examples:
--linelength=120
--recursiveβ Search for files to lint recursively. Each directory given in the list of files to be linted is replaced by all files that descend from that directory. Files with extensions not in the valid extensions list are excluded. it goes deep. π³οΈ--exclude=pathβ Exclude the given path from the list of files to be linted. Relative paths are evaluated relative to the current directory and shell globbing is performed. This flag can be provided multiple times to exclude multiple files.
Examples:
--exclude=one.cc
--exclude=src/*.cc
--exclude=src/*.cc --exclude=test/*.cc
--extensions=extension,extension,...β The allowed file extensions that cpplint will check.
Examples:
--extensions=c,c++,cc,cpp,cu,cuh,cxx,h,h++,hh,hpp,hxx
π§ THE FANCY ONES π§
--includeorder=default|standardcfirstβ For thebuild/include_orderrule, the default is to blindly assume angle bracket includes with file extension are c-system-headers (default), even knowing this will have false classifications. The default is established at google.standardcfirstmeans to instead use an allow-list of known c headers and treat all others as separate group of"other system headers". The C headers included are those of the C-standard lib and closely related ones.--config=filenameβ Search for config files with the specified name instead ofCPPLINT.cfg. (yes you can rename your config file. custom era. π)--headers=x,y,...β The header extensions that cpplint will treat as.hin checks. Values are automatically added to the--extensionslist.
(by default, only files with extensions ['cuh', 'h', 'h++', 'hh', 'hpp', 'hxx'] will be assumed to be headers)
Examples:
--headers=cuh,h,h++,hh,hpp,hxx
--headers=hpp,hxx
--headers=hpp
βοΈ CPPLINT.cfg β the per-directory config era βοΈ
cpplint.py supports per-directory configurations specified in CPPLINT.cfg files. A CPPLINT.cfg file can contain a number of key=value pairs. Currently the following options are supported:
set noparent
filter=+filter1,-filter2,...
exclude_files=regex
linelength=80
root=subdir
headers=x,y,...
"set noparent"option prevents cpplint from traversing directory tree upwards looking for more.cfgfiles in parent directories. This option is usually placed in the top-level project directory.- The
"filter"option is similar in function to--filterflag. It specifies message filters in addition to the|_DEFAULT_FILTERS|and those specified through--filtercommand-line flag. "exclude_files"allows to specify a regular expression to be matched against a file name. If the expression matches, the file is skipped and not run through the linter. byeee π"linelength"allows to specify the allowed line length for the project.- The
"root"option is similar in function to the--rootflag (see example above). Paths are relative to the directory of theCPPLINT.cfg. - The
"headers"option is similar in function to the--headersflag (see example above).
CPPLINT.cfg has an effect on files in the same directory and all sub-directories, unless overridden by a nested configuration file. it's giving ancestral rules that trickle down the tree. π³
Example file:
filter=-build/include_order,+build/include_alpha
exclude_files=.*\.cc
The above example disables build/include_order warning and enables build/include_alpha as well as excludes all .cc from being processed by linter, in the current directory (where the .cfg file is located) and all sub-directories. look at her go. π
π«Ά and that's the whole page bestie. keep every detail, break zero rules, lint responsibly, and remember: not a substitute for a code review. no cap.
this page is cpplint version 2.0.2, dated July 2026 β and honestly? she ate. mwah. πβ¨ππ¦πΈππβπ
π¦ where this page comes from
- ubuntu stonking: cpplint 2.0.2-4 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms