mr-edd.co.uk http://www.mr-edd.co.uk Horsing around with the C++ programming language http://www.mr-edd.co.uk/static/rss.png http://www.mr-edd.co.uk Copyright Edd Dawson Wed, 21 Jul 2010 00:00:01 GMT 720 The problem with DAG-driven builds http://www.mr-edd.co.uk/blog/problem_dag_driven_builds slam has served me reasonably well for a while now, but as soon as it came off the conveyor I knew there were things that I'd never be able to do with it. In fact, it was only a short while after I released it that I started thinking about a successor. I started out with the notion of creating something like SCons, but easier to usethe reasons that I have shied away from SCons are probably a subject for another post. The idea would be to provide an API in a powerful scripting language such as Python or Lua that allowed the construction of a directed acyclic graph (DAG) representing the build. However, after creating a prototype and thinking about it some more, I'm gradually coming to the conclusion that the DAG-driven abstraction underlying systems such as SCons and make is inadequate for describing some types of build that exist in the real world. Wed, 21 Jul 2010 00:00:01 GMT sigfwd: forwarding Qt signals anywhere http://www.mr-edd.co.uk/blog/forwarding_qt_signals_anywhere Just when I started feeling more comfortable with your templates, you mix them up with Qt internals!!long-suffering coworker Sat, 10 Jul 2010 00:00:01 GMT Turning an insurance renewal in to a lambda expression http://www.mr-edd.co.uk/blog/tetris_effect A recent post on Hacker News pointed to Wikipedia's article on the Tetris effect. I've recently had to dig much deeper in to the Boost meta-programming library than I have before for the sake of writing sigfwd's functor_traits mechanism. A few nights ago I woke up from a dream in a fit of frustration because I just couldn't fucking well manage to turn my motor insurance renewal in to an MPL lambda expression. I'm not sure whether to laugh or cry Sat, 10 Jul 2010 00:00:01 GMT Improving on: Dr. Dobbs - Associate Mutexes with Data to Prevent Races http://www.mr-edd.co.uk/blog/associate_mutexes_to_prevent_races Herb Sutter has recently posted the next installment in his Effective Concurrency series. This time he outlines a technique to associate data with a particular mutex. The idea is to ensure that race conditions are eliminated by construction. It's a very nice technique, but I think we can go a little bit further in shoring-up the protection mechanism. In Herb's example code, there are run time assertions that determine whether the associated mutex is locked prior to accessing the data. If we re-phrase the code, we can actually ensure that at compile time. Sat, 29 May 2010 00:00:01 GMT thread_local: a read/write lock example http://www.mr-edd.co.uk/blog/thread_local_rw_lock On discovering that boost::thread_specific_ptr works in what I would consider a dangerous fashion, I wrote my own thread-local storage facility. It's the first time I've had the chance to use the newer mutex types introduced in recent releases of boost. I think the code makes quite a nice self-contained example of how to create a so-called read/write lock in terms of the primitives provided by the boost thread library, so I decided to post it here. Tue, 04 May 2010 00:00:01 GMT Visual C++ 2010 available http://www.mr-edd.co.uk/blog/vc2010_available This is about a week late, but Microsoft's Visual C++ 2010 is now available. As with the 2005 and 2008 products, there's a free to use Express edition. Sun, 25 Apr 2010 00:00:01 GMT Introducing nanohook http://www.mr-edd.co.uk/blog/introducing_nanohook One of the problems I've encountered when porting pexl to Windows is that code can behave differently depending on whether its standard streams are connected to a console or a pipe. Take the following simple C program, for example:#include <stdio.h> int main() { int age = 0; printf("How old are you?: "); scanf("%d", &age); return 0; } You can compile and run this at a command prompt on Windows and it will work just fine. Strictly speaking however, there should be a call to fflush(stdout) between the printf and scanf. Indeed when you run this program with its stdout connected to a named pipe, the question won't appear at the other end. If it were possible to replace the WriteFile and/or WriteFileExwhich are the lowest level user-space functions for writing output to HANDLEs all writes eventually call one of these, as far as I understand functions in the child process with equivalents that also flush their output when writing to stdout or stderr, pexl would be able to reproduce the output of these programs faithfully. nanohook is a library that allows just such replacement functions to be installed at run-time, at the machine code level. Sat, 03 Apr 2010 00:00:01 GMT C++11 final committee draft accepted http://www.mr-edd.co.uk/blog/cpp11_fcd Interesting news from Sutter's Mill this afternoon. The biggest news is that this afternoon we voted in the final remaining feature changes to C++0x, and to much applause then unanimously approved the text for international ballot as a Final Committee Draft (FCD).I'm happy and somewhat surprised to see that export has been removed (and not merely deprecated) and function throw specifications have been replaced with a noexcept keyword. noexcept will serve a similar purpose to an empty throw() specification in the current standard. Other types of throw specifications are deprecated. There's more detail on Herb's blog. Sat, 13 Mar 2010 00:00:01 GMT A problem with boost::thread_specific_ptr http://www.mr-edd.co.uk/blog/thread_specific_ptr_problem This week I hit a problem when using boost::thread_specific_ptr. The short story is, don't use one unless it's in static storage. Wed, 17 Feb 2010 00:00:01 GMT Neat trick: iterating over consecutive pairs of adjacent indices http://www.mr-edd.co.uk/blog/pair_iteration_trick Serving up a somewhat daft post today, but it's nice to bump in to stuff like this now and again; one of those things that you come across and say Huh! How the smeg have I not seen that before?. Well, maybe you've seen it, but it's new to me. Tue, 09 Feb 2010 00:00:01 GMT