Jul 13, 2012

Parsing Lint Errors In Eclipse

In my 2010 post on Using Lint In Eclipse, I mentioned the one missing piece was having an error list that was clickable and would take you to the offending line in source code. Thanks to Colin O'Flynn's comment and blog post I was able to get things working just the way I want. I had to modify several of the steps in Colin's post. Here are the specific steps I took using the Juno release of Eclipse.

Self Promotion

You might want to check out my 4 hour course on Eclipse. It’s now live on Pluralsight.

Install the RegEx Parser Plugin

imageUsing the Help->Install New Software… option I used the Add… button and put in a path of http://www.isystem.si/eclipseUpdate/regExErrorParser/, and installed the regular expression parser.

Setup the RegEx Parser Plugin

Just to be safe I copied RegEx  configuration file errParserExpressions.properties located in my eclipse plugins folder …\eclipse\plugins\si.isystem.regExErrorParser_1.0.8.i9_9_72_20090403_134038\regex

I then replaced the contents of errParserExpressions.properties with the text specified in Colin's post:
logLevel = 0
info = 1, 2, 3:LINT Info: (.*?):([0-9]+) (.*)\n \
       0, 0, 1:LINT Info (.*)\n 
warning = 1, 2, 3:LINT Warning: (.*?):([0-9]+) (.*)\n \
          0, 0, 1:LINT Warning (.*)\n
error = 1, 2, 3:LINT Error: (.*?):([0-9]+) (.*)\n \
        0, 0, 1:LINT Error (.*)\n
Exit Eclipse and restart to that it picks up the changes to this file.


Create a new build configuration

imageCreating a new build configuration starts with using the Project->Build Configurations->Manage… option to open the Manage Configurations dialog. Alternately, if this item is disabled in your perspective, try right-clicking on the project and selecting Build Configurations->Manage from there.


SNAGHTML6080128Click the New… button and give the new configuration a name.

Modify the ToolChain

Now open up the project properties dialog. NetBurner uses the managed build system so by default you can't uncheck the Use default build command option. You can enable this by using the Tool Chain Editor.

SNAGHTML60ab96eI believe I had to first uncheck the option for Display compatible toolchains only. Then I was able to select another toolchain. I intially picked one of the GCC options, but later after turning off the automated make file (see next step) I came back here and selected the No ToolChain from the dropdown.  Prior to disabling the makefile generation this option was not present.  Once this was done I could switch back to the C/C++ Build tab and…


Specify the Lint command as your build command.


…uncheck the Use default build command and the Generate Makefile automatically check box.   Then on the Build command text box I entered the command line to launch lint. The line I used is shown below.

My build command:  (for copy and paste convenience)

c:\lint/lint-nt.exe C:\lint\netburner.lnt  ${ProjDirPath}\project.lnt   ${ProjDirPath}\src\*.cpp

The contents of the netburner.lnt and project.lnt were discussed in the previous post. I also had to tell lint which files to process. I don't know how Colin got around doing this, but without the line above that specifies *.cpp, lint does nothing. Note that I have all my files in a folder named "src" inside my project directory. If you just have yours at the root of the project you won't need the \src specifier.

Change the Behavior

SNAGHTML6148229Click on the Behaviour tab (someone on the Eclipse project must be British) and Clear the Clean check box and remove anything in the Build (increment build) text box. I had to leave the Stop on first build error check box enabled. If I cleared it, Eclipse would automatically add a –k option to my build command, which caused lint to fail.

Turn on the RegEx Error Parser (Update to original post)

SNAGHTML715bf5dEclipse needs to know you want to parse the output with the RegEx parser. Using the C/C++ Build->Settings  tab click on the Error Parsers tab and turn off any parsers that are enabled and turn on the RegEx parser as shown.


Linting A Single File

SNAGHTML6892f6bThe only change I made to lint a single file was I removed the ${ProjDirPath}\src\*.cpp portion of the build command and then on the Behaviour tab, in the Build (Incremental build) text box I added -u ${selected_resource_loc}.

The Lint Build

imageMy build drop down now has my new build and to lint my project I no longer have to use the External tools command. I just use this new build.




The command console looks very similar while the project is being linted.


imageBut the problems tab now shows a clickable list of warnings and errors.

About Me

My photo
Tod Gentille (@todgentille) is now a Curriculum Director for Pluralsight. He's been programming professionally since well before you were born and was a software consultant for most of his career. He's also a father, husband, drummer, and windsurfer. He wants to be a guitar player but he just hasn't got the chops for it.