JB Enterprises

JB Enterprises - Johan Bezem

Interim Management & Consulting

JB Enterprises - Blog


Using PC Lint in eclipse – no plug-ins required

I've been tinkering with Eclipse to see if I can make PC Lint run from inside Eclipse. Of course, running Lint as an external tool is always an option, but I couldn't get Eclipse to recognize the Lint warnings and display them in the 'Problems' tab. From my testing and what I could find on the Internet, it seems that the output of so-configured external tools is not run by the error parsers installed.

What I found on the Internet suggested that I have to use a special error parser, configure it, and then it would run. Now, I have nothing against using extra tools if that's the way to achieve what I want, but if I can do without, I consider that a better solution, since every tool used is another tool to learn how to use. And delivering configurations to my customers, it's not my business model to make myself indispensable, on the contrary.

So, after experimenting some more, I have found a way to use PC Lint with Eclipse (I used Ganymede for testing) without resorting to additional tools or plug-ins. Be aware, I'm not an Eclipse expert in any sense, so there may be many more and possibly better ways to achieve this. I'd be happy to get some comments with further tips.

The key is to add a new 'build target' for running PC Lint:

  • On the properties dialog for the workspace (right-click and select 'Properties'), in the 'Builders' section, check that the "CDT Builder" is selected.
  • In the 'C/C++ Build' section, click on "Manage Configurations..." and add a configuration for running Lint.
  • Select the configuration from the drop-down box.
  • On the 'Builder Settings' tab, deselect the "Use default build command" and instead provide the path to the Lint executable, eg. "C:\Lint90\LINT-NT.EXE". Specify the "Build location", from which directory you want Lint to run, either absolute or using the buttons offered.
  • On the 'Behaviour' tab, deselect "clean", and provide the parameters to Lint in the (selected) 'Build (Incremental build)' text box.

Be aware that these indications all assume some kind of a general build or make environment, so the names themselves do not indicate the possibility for running a single program. If you use a Makefile concept for running Lint, you may use that as well, and 'clean' might even make sense.

  • In the 'Settings' section of 'C/C++ Build', make sure that all CDT parsers (or at least the "CDT GNU C/C++ Error Parser") are selected.

And that's it.

OK; one final thing remains. We now need to coerce Lint into providing warnings in a format similar to the GNU C/C++ compiler. This can be achieved by some Lint options in your option file. I use:

  // Output options: One line, file info always; Use full path names
  -hF1
  +ffn
  // Normally my format is defined as follows:
  //-"format=%(\q%f\q %l %C%) %t %n: %m"
  // For eclipse-usage, the GCC error format is necessary,
  // since we have only the default eclipse error parser available.
  -"format=%(%f:%l:%C:%) %t %n: %m"
  // And also for eclipse, the reference locations provided by
  // Lint, put into square brackets "[Reference: File: ... Line: ...]"
  // are not correctly handled, therefore we switch them off.
  // Enable warning 831 if you are interested.
  -frl
  // Do not break lines
  -width(0)
  // And make sure no foreign includes change the format
  +flm

If you want to know more than my comments are telling you, check the Lint manual for details.

Now, don't get me wrong: I will not switch from my trusted SlickEdit to Eclipse. But, as a consultant, I cannot always pick and choose. And running Lint from Eclipse, having a way to jump from warning to warning, definitely beats manual navigation.

Happy Linting!

August 18th, 2009

Valid XHTML 1.0 Strict Valid CSS www.bezem.de: © 1999 – 2019 by Johan Bezem, all rights reserved.
This page was last updated on Tuesday, 2017-07-25 17:31.