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.
wget https://courses.cs.washington.edu/courses/cse333/23wi/cpplint.py
cpplint.py
is in the same directory
as the code being checked.
If it is located elsewhere, use an appropriate file path to access it
or put its directory in your shell $PATH
variable.
./cpplint.py: Permission denied
when trying to use cpplint.py
, give the file execute
permissions by running the command:
$ chmod +x cpplint.py
.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
.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