How to use CPPLint in Eclipse CDT

Errors found by CPPLint in Eclipse CDT
Errors found by CPPLint in Eclipse CDT

CPPLint is a tool created by Google that can be used to check a C++ source or header file. It is a single file Python script. It would be nice to apply CPPLint on a C++ file in Eclipse CDT whenever it is saved. This is possible by using the CPPStyle plugin for Eclipse. It runs cpplint.py on a saved C++ file and displays the reported errors conveniently in a Problems view, as shown in screenshot above.

  • First install CPPLint:
$ sudo curl -L "http://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py" -o /usr/bin/cpplint.py
$ sudo chmod a+x /usr/bin/cpplint.py
  • Install CPPStyle plugin in Eclipse. Open Help -> Install New Software and the URL http://wangzw.github.io/CppStyle/update to install it. Eclipse will be restarted after that.

  • Open Window -> Preferences -> C/C++ -> CPPStyle. Enable the Enable cpplint on save option.

  • Edit and save any C++ file. CPPLint will be run on it. If there are any problems, you can see the output in Console view or see them listed nicely in Problems view.

Tried with: CPPStyle 1.0.0 and Eclipse Luna 4.4.1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s