Sunday 25 April 2010

C++ And Bug Finding Tools


I work as a C++ programmer and one thing that always amazes me is the difference in compilers, we use compilers as a way to catch some of our errors along with the obvious use of compiler! We compile on Windows (VC and MinGW), Linux and Solaris. Each one seem to have different analysis tools built into the compiler that picks up different bugs/warnings, sometimes only the Solaris catches shadowed variables and so on.

Yes we have all the compilers set up to some pretty high warning levels and warnings are treated as errors. As we have a large test suite we can run against our code we also get to catch a lot of edges cases from compiling and running on different platforms. The benefits to Windows (where our main user base is) users is reasonable and certainly worth the programmer time spent maintaining our own internal build of the alternative operating systems.

Ok the company I work at does ship on Linux and Solaris but the builds we do locally are internal to our office, the main builds are handled elsewhere.

We also run over the code with the Microsoft static analyser, Coverity and recently we have started to use valgrind. They all catch bugs that would be difficult to find otherwise.

We obviously have lots of other bugs to deal with but this set of tools certainly helps. Some may think we are excessive but once the systems are in place compiling and running our tests is not a time consuming task. Even valgrind can be left to run over night so time is not wasted.

So if you work in on C/C++ application and the code you work in standard C/C++ (not gui stuff) cross compiling help you catch bugs and gives you access to valgrind. Plus running linux is so easy now you have virtualisation.

No comments:

Post a Comment