Skip to main content

Automatic consistency checking

Yesterday evening I slapped together a small tool for consistency checking of large codebases. It's written in a similar spirit as Boost's inspect tool, just slightly more sophisticated. Written in C#, it allows you to plug in your own checks easily. At the moment, I have a generic RegEx checker (just looks if a regular expression matches) and a line ending checker in my core tests and a bunch of niven specific ones (license, interfaces with struct and not with class, file header, @file comment in header matches file name, include guards are not reused, missing @author, outdated mail addresses). Some example output:

Loading checker from 'Checks'
         .. 'CrLfCheck'
 .. 1 checker loaded
Loading checker from 'nivenChecks'
         .. 'CheckFileHeader'
         .. 'OutdatedMailAnteru'
         .. 'AuthorCheck'
         .. 'IncludeGuards'
         .. 'StructInterfaces'
         .. 'FilenameInHeader'
 .. 6 checker loaded


Running checks for 'archive.h'
 ++ OK  ... 0 failures


Running checks for 'core.h'
    Include guards      : Include guard already used
        >> Line: 9: The include guard 'NIV_CORE_H' has been already used
    Interfaces          : Interface defined with 'class'
        >> Line: 17: Interface 'IFileSystem' uses 'class' instead of 'struct'
 -- FAILED  ... 2 failures


39 failures (101 files total)

It was written against the .NET Framework 2.0, but it should work with Mono as well. On startup, it loads up your assembly and pulls the checks out of it, so it's really easy to extend. I'm running it now along with the build to see which files need some attention. By the way, anonymous comments are enabled, so you can tell me what features would you like to see from such a litte helper?

C++ tricks, #4: Binding to overloaded member functions

Anyone who is developing with C++ knows the joys of member functions and pointers to member functions (you know, those SomeLongType (ClassName::*)(Param)-typed beasts). Today, I had a problem, I needed to bind (using Boost.Bind) to an overloaded member function, and to make things interesting it was const as well. The problem is with just a plain &Class::functionName (i.e., boost::bind (&Class::fun, &instance, _1, ...)), it cannot resolve which function you mean (giving you usually pages of compiler output). The deal is, how to disambiguate, and the solution is of course cast to your type. This leads to something like

boost::bind (static_cast<int (ClassName::*)(const Param& p1) const> (&ClassName::Function), &instance, _1)

Hope this helps somebody as it took me quite some time to figure this out.

Don't leave home

I'm still music addicted, but I didn't come around to post something in my music category for quite some time now. Here we go, with another "must-have-heard" song from one of the best artists I ever had the chance to see: Dido, with her incredible song "Don't leave home" from here album "Life for Rent". I'm pretty sure you have heard it already, as it was a quite successful. As every Dido fan knows, it is not a song about love, but about addiction, but feel free to interpret it in your own way. What you should do is watch the video, it is really wonderful. Just make sure it's silent while listening to this song and try to listen to the lyrics and think into a situation where someone is in need, and this song gets a really deeper meaning. It's a song that cheers me up every time I hear it, and even after having heard it a lot of times, I'm still fascinated by this melancholic, yet hopeful song... "So close the blinds and shut the door / you won't need other friends anymore".

R600 is out

ATi/AMD's next-generation graphics card is out. 6 months late after the obviously shocking good G80, AMD tried to do a hat-trick and pull out a G80 killer, but initial reviews (Beyond3d architectural review, various benchmarks) show that they failed with this. I can only suspect, but I believe that the G80 chip did really surprise them, they were surely expecting a beefed up G71 and now this IQ and performance wonder comes out from the skies with the fully scalar architecture. This is a really sad day, I hoped for at least competitive performance, but in this situation, nVidia has no real reason to reduce the price of their G80 lineup (which was monopoly-high the last 6 months, giving nVidia very high margins).