← 返回命令列表

Linux command

cpplint 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Check single file

cpplint [file.cpp]

Check multiple files

cpplint [file1.cpp] [file2.cpp]

Recursive directory check

cpplint --recursive [src/]

Filter specific categories

cpplint --filter=-whitespace,+build [file.cpp]

Set line length

cpplint --linelength=[120] [file.cpp]

Output in different format

cpplint --output=[vs7] [file.cpp]

说明

cpplint is a static code checker for C++ that verifies code against Google's C++ style guide. It checks for style errors, formatting issues, and common programming mistakes to enforce consistent code standards across projects. The tool examines source files for compliance with naming conventions, spacing rules, comment formatting, header guard patterns, and many other style requirements. It helps teams maintain uniform code style and catch common errors before code review. Originally developed by Google for internal use, cpplint is now maintained as an open-source project. While designed specifically for Google's style guide, its rules can be filtered and customized for projects with different conventions.

参数

--recursive
Check files in subdirectories recursively
--filter=_-/+categories_
Enable/disable specific warning categories
--linelength=_length_
Maximum line length (default 80)
--extensions=_list_
File extensions to process
--headers=_list_
Header file extensions
--output=_format_
Output format: emacs, vs7, eclipse, junit, sed, gsed
--counting=_type_
Count errors: total, toplevel, detailed
--root=_dir_
Project root for header guard paths
--exclude=_pattern_
Exclude files matching pattern

FAQ

What is the cpplint command used for?

cpplint is a static code checker for C++ that verifies code against Google's C++ style guide. It checks for style errors, formatting issues, and common programming mistakes to enforce consistent code standards across projects. The tool examines source files for compliance with naming conventions, spacing rules, comment formatting, header guard patterns, and many other style requirements. It helps teams maintain uniform code style and catch common errors before code review. Originally developed by Google for internal use, cpplint is now maintained as an open-source project. While designed specifically for Google's style guide, its rules can be filtered and customized for projects with different conventions.

How do I run a basic cpplint example?

Run `cpplint [file.cpp]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --recursive do in cpplint?

Check files in subdirectories recursively