Products, the Universe and Everything

The Riverblade Developer's Blog

Beth demonstrating Visual Lint at the ACCU Conference 2008  Anna taking part in a discussion panel at the European Software Conference 2007 

Welcome to our developer's blog. We hope that this forum provides an insight into us, our products and how we develop them. Please feel free to write to us if you have anything to add to any of the posts here.

Current Entries | Archives |

Walkthrough: Configuring Visual Lint 3.0 to use the CppCheck open source C++ analysis tool
Monday, February 28, 2011

Visual Lint 3.0 should be released at the end of March, so this is an appropriate time to take a step back from the nuts and bolts of coordinating a software release and talk a little bit about some of the new stuff.

One of the most obvious changes in Visual Lint 3.0 is that it supports more than one analysis tool. In fact, the current beta currently supports three tools - PC-lint (naturally!), CppCheck and Google CppLint  - with others (e.g. FxCop for C#, TICS Basic for C# and FindBugs for Java) in development.

Of these, CppCheck is one of the most interesting in that it is a rather rare beast - an open source C++ static analysis tool.

Configuring Visual Lint 3.0 to use CppCheck is pretty straightforward. The first step is (predictably) to run the Configuration Wizard:

Once invoked, it will display a list of supported analysis tools and allow you to select the one you wish to configure:

By comparison to PC-lint, CppCheck is a doddle to configure. There are no indirect files, and it is designed to work without knowing about include folder settings, preprocessor symbols etc. As a result, configuration is usually just a matter of  installing it and telling Visual Lint where it is.

If you don't have CppCheck installed, the "More Information" button on the "Select CppCheck installation folder" page in the Configuration Wizard will take you directly to its  download page on SourceForge.

Once installed, clicking the "Find it for me, please..." button on the Wizard page will locate the installation and configure Visual Lint accordingly (you can also browse for it manually, of course):

If you need to tweak the analysis configuration slightly, there are additional settings you can access via the "Configure Analysis Tool" command (the same one used to edit PC-lint std.lnt indirect files). These allow system and project include folders to be configured along with preprocessor symbols if required.

In practice, we would recommend you generally avoid using system include folders with CppCheck as doing so slows it down tremendously for very little benefit - but we have found the project additional include and preprocessor definition options to be useful in some cases.

The CppCheck online manual is accessible within the development environment in the same way as the PC-lint manual, and using exactly the same command:

...and finally: the analysis itself. Everything works in exactly the same way as the PC-lint integration, but using CppCheck instead.

It is interesting to compare the two tools from an integration and usage perspective. CppCheck is far less fiddly to configure, but reports far fewer issues than PC-lint on the same codebase (depending on your perspective, the latter can obviously be seen as either a good or a bad thing). Depending on how you configure it, CppCheck can either run much faster or far slower than PC-lint (the latter especially true if system headers are enabled - PC-lint seems to cope much better with those).

If required, analysis using either tool can of course be accelerated using our IncrediBuild/XGE integration.

Either way, CppCheck offers a good introduction to static analysis, so if you are looking to analyse a C++ codebase and do not yet have access to PC-lint it is one which is definitely worth checking out.

Analysing a sample codebase with CppCheck:

Analysing the same codebase with PC-lint and our most aggressive warning policy:

Finally, if you would like to try CppCheck you can download it from SourceForge.

Posted by Anna at 16:33 | Get Link