cpplint

cpplint.py is a style checker for C and C++ that checks code for consistency with the . It is NOT a full compiler for C/C++ programs, so it does not examine the detailed semantics of your code, but it does a good job of checking general code organization and layout. You should use it to check all of your code before submission as it will be factored into your grades.

Getting a Copy

Browser
(right-click to save)
Terminal
wget https://courses.cs.washington.edu/courses/cse333/23wi/cpplint.py
Gitlab
A copy will be pushed along with the Homework 0 files to your .

Checking C Code (.c files and .h headers with C declarations)

Assuming that the cpplint.py file is in your current directory, the following command will check C source files (note the --clint option):

$ ./cpplint.py --clint [files to check]

If you want to check more than one file, just put them as separate command-line arguments (i.e., separate their paths with spaces). The output should look something like these examples:

          $ ./cpplint.py --clint hw1/LinkedList.c
          hw1/LinkedList.c:44:  Missing space before ( in while(  [whitespace/parens] [5]
          hw1/LinkedList.c:44:  Missing space before {  [whitespace/braces] [5]
          hw1/LinkedList.c:108:  Missing space before ( in if(  [whitespace/parens] [5]
          hw1/LinkedList.c:108:  Missing space before {  [whitespace/braces] [5]
          Done processing hw1/LinkedList.c
        
          $ ./cpplint.py --clint ex1.c
          Done processing ex1.c
        

Checking C++ Code (.cc files and .h headers with C++ declarations)

Assuming that the cpplint.py file is in your current directory, the following command will check C++ source files (note the LACK of --clint option):

$ ./cpplint.py [files to check]

If you want to check more than one file, just put them as separate command-line arguments (i.e., separate their paths with spaces). The output should look something like these examples:

          $ ./cpplint.py ex9.cc
          ex9:10:  Closing ) should be moved to the previous line  [whitespace/parens] [2]
          Done processing ex9.cc
          Total errors found: 1
        
          $ ./cpplint.py ex10.cc
          Done processing ex10.cc