Skip to content

Cpplint Reference

This page provides a list of common cpplint errors, along with links to the correct styling approach. Understanding these errors will help you debug and improve your code to meet the Google C++ Style Guide requirements. Use this reference to identify and resolve style issues efficiently.

Access Specifier Indent Detected

Section titled “Access Specifier Indent ”
Terminal window
public: should be indented +1 space inside class ClassName [whitespace/indent] [3]
Do not leave a blank line after "public:" [whitespace/blank_line] [3]
private: should be indented +1 space inside class ClassName [whitespace/indent] [3]
Do not leave a blank line after "private:" [whitespace/blank_line] [3]
protected: should be indented +1 space inside class ClassName [whitespace/indent] [3]
Do not leave a blank line after "protected:" [whitespace/blank_line] [3]

Reference to style

Class Blank Space Detected

Section titled “Class Blank Space ”
Terminal window
Redundant blank line at the start of a code block should be deleted. [whitespace/blank_line] [2]
Redundant blank line at the end of a code block should be deleted. [whitespace/blank_line] [3]
Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]

Reference to style

Class Data Member Not Detected

Section titled “Class Data Member ”
Terminal window
Done processing driver.cc

Reference to style

Class Name Not Detected

Section titled “Class Name ”
Terminal window
Done processing driver.cc

Reference to style

Terminal window
Lines should be <= 80 characters long [whitespace/line_length] [2]

Reference to style

Terminal window
At least two spaces is best between code and comments [whitespace/comments] [2]

Reference to style

Constant Not Detected

Section titled “Constant ”
Terminal window
Done processing driver.cc

Reference to style

Control Structures Detected

Section titled “Control Structures ”
Terminal window
# General Errors
Redundant blank line at the start of a code block should be deleted. [whitespace/blank_line] [2]
Redundant blank line at the end of a code block should be deleted. [whitespace/blank_line] [3]
{ should almost always be at the end of the previous line [whitespace/braces] [4]
Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
Empty loop bodies should use {} or continue [whitespace/empty_loop_body] [5]
# Else Errors
An else should appear on the same line as the preceding } [whitespace/newline] [4]
Else clause should be indented at the same level as if. Ambiguous nested if/else chains require braces. [readability/braces] [4]
If an else has a brace on one side, it should have it on both [readability/braces] [5]

Reference to styles

Terminal window
No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5]

Reference to style

Function Mostly Detected

Section titled “Function ”
Terminal window
Redundant blank line at the start of a code block should be deleted. [whitespace/blank_line] [2]
Redundant blank line at the end of a code block should be deleted. [whitespace/blank_line] [3]
Extra space after ( in function call [whitespace/parens] [4]
Extra space before ( in function call [whitespace/parens] [4]
Missing space before { [whitespace/braces] [5]
Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
{ should almost always be at the end of the previous line [whitespace/braces] [4]

Reference to style

Header Guards Falsely Detected

Section titled “Header Guards ”
Terminal window
#ifndef header guard has wrong style, please use: FILE_PATH [build/header_guard] [5]
#endif line should be "#endif // FILE_PATH" [build/header_guard] [5]

Reference to style

Include File Falsely Detected

Section titled “Include File ”
Terminal window
Include the directory when naming header files [build/include_subdir] [4]

Reference to style

Indentation Not Detected

Section titled “Indentation ”
Terminal window
Done processing driver.cc

Reference to style

Terminal window
*** missing separator. Stop.

Reference to style

Namespace Not Detected

Section titled “Namespace ”
Terminal window
Done processing driver.cc

Reference to style

Newline Character Detected

Section titled “Newline Character ”
Terminal window
Could not find a newline character at the end of the file. [whitespace/ending_newline] [5]

Reference to style

Variable Not Detected

Section titled “Variable ”
Terminal window
Done processing driver.cc

Reference to style