Tuesday, November 03, 2009

Boost Spirit 2.1

I'm very impressed by what Joel, Hartmut and the rest of the folks have done with the 2.1 release of Spirit.  The syntax has been improved, the code is much neater and more powerful – bravo guys! 

If you use C++ and have a need for a parser do yourself a favour and check out Spirit.

Spirit 2.1 will be in Boost 1.41.0, which is due for release any time now (it's currently in beta).  Until then you can read the pre-release documentation.

Wednesday, July 08, 2009


Geektastic!  The company that develops NDepend, the sensational source code analysis tool for .NET, has just released a C++ counterpart.  I intend to spend a great deal of time analysing our code with CppDepend.  Available for free as a beta. 

[Via Kate Gregory.]

Saturday, May 23, 2009

VMWare Server 2 Remote Console and Synergy

I've got VMWare Server 2 install on one of my machines here and I was trying to use the Remote Console (which installs as a Firefox extension) to connect to a Windows XP VM I was creating.  But no dice.  The keyboard and mouse inputs were not being redirected to the VM.

After trying a bunch of things I stumbled on turning Synergy off.  Voila, the mouse and keyboard works as expected.

[Incidentally my recommendation is to use the Synergy+ client; the original Synergy client appears to be pretty much abandonware and the Synergy+ folks are doing a great job at fixing bugs.]

So there's my tip of the day:  If you find your keyboard and mouse not working as expected with VMWare Server 2's Remote Client take a took in your system tray.  If Synergy is running turn it off and see if Remote Client responds.  Worked for me!

Monday, April 13, 2009

Code Snippets for C++ in VS2005

Visual Studio 2005 introduced the concepts of code snippets. Handy little chunks of commonly-used code that are easily inserted to your own with some Intellisense magic. Hit a keypress, choose the snippet, fill in any fields and voila.

C# and VB users were spoilt; MS supplied a bunch of snippets to do many common tasks. Iterating over containers, creating regions, defining classes…many common tasks were snippetified. Further, there were many more online.

Alas, C++ users were left in the dark with no snippet support at all.

Thankfully the release of the "Microsoft Visual Studio 2005 IDE Enhancements" addressed that issue (also known as the VS2005 "Powertoys"). After installation you get – among a few other questionably useful tools - C++ snippet support in VS2005. There are only two problems. 1) If you're using Vista you get a bizarre error 1 when you try to run the installer. 2) You don't get any C++ snippets installed. Instead Microsoft makes the C# snippets available in C++. Thanks guys. Anyway, let's address those problems.

1) The issue here is that Vista requires administrator privileges to install this package. Had the install package been an exe we'd have been fine; shift-right click and select "Run as Administrator". Alas it's an MSI so we'll have to find another way. The simplest, as described by the MS UK Dev Team, is to fire up a command shell, running it as admin (open the start menu, type 'cmd' then shift + right-click the cmd.exe icon), change to the directory where you downloaded the PowerToy installer then execute the command:

msiexec /i "VSSDK_PowerToys.msi"

Then follow the GUI installer as normal. Oh, you'll need to exit from all VS2005 instances.

[You may notice – well, I did – that Visual Studio will have a bit of a conniption fit when you restart. It appears that it's setting itself up for the first time again. Not sure why. Thankfully all my keybindings etc remained intact and there were no noticeable problems but YMMV.]

2) Once everything is installed correctly you should find that the "Tools->Code Snippets Manager" should now have "Visual C++" listed as a language. Good sign. However by looking through the supplied list of snippets you'll find they're all actually C# snippets. You'll want to write your own C++ snippets. To do that you'll need a snippet editor since writing the XML by hand is tedious (far from impossible but annoying).

Of the bunch of tools I found that edited snippets only Snippy supported C++ snippets. Snippy works fine but doesn't seem to have a binary distribution so you'll need to download and build it (a VS2005 solution file is supplied). After you run it create your own snippets and save them somewhere (like "Users\YourName\Documents\Visual Studio 2005\Code Snippets\Visual C++\YourSnippets"). You can then add those snippets to VS2005 using the Snippet Manager.

I haven't discussed the format of a snippet, it's pretty easy to figure it out from Microsoft's documentation. But here's one to get you started. If people ask nicely I'll try and post more.

And that's it! Now you should be ready to create your own wicked-cool C++ snippets. Let me know if you have any rippers!

1: The error is something like: "Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor." I love how the error makes it so clear that administrator privileges are required.

Wednesday, April 23, 2008

Code Camp '08

Once again I'm going to miss Code Camp.  Too many other things going on (holiday to book, birthday party x 2, BBQ Friday, gathering to go to Sunday) to justify heading away for three days to geek out.  In other words my girlfriend will be über cheesed if I go.  ;)

Have fun if you're going!  Wish I was there too.

PS I've got a plan for next time.  I'll present on some topic - that'll be way easier to sell to my SO than if I'm just tagging along...

Friday, April 11, 2008

Building Boost 1.35

I'm a big fan of the boost library for C++ development.  They're incredibly well designed and implemented, generally cross-platform, and quite well documented.  In short, they're awesome.

However, I regularly have issues building them (on Windows with the VS2005 compiler).  Thankfully I'm not alone.  Kevin Heifner ran into the same problems I did when trying to build the recently released 1.35 and documented a work-around.  Thanks Kevin!  It worked a treat.

The summary is that the Boost Consulting group, who usually put together a nice installer, haven't yet published one for 1.35.  Further, following the instructions on the Getting Started page that describe how to build boost led me astray.  With hindsight I think the major problem was that the "stage" directory mentioned in the example needs to be created before the build commences.  Anyway, Kevin provides an alternative set of command line options for bjam:

cd "C:\Program Files\boost\boost_1_35_0"

bjam --toolset=msvc --build-type=complete --prefix="c:\program files\boost\boost_1_35_0" install

Then just configure your projects Additional Library Directories to include "C:\Program Files\boost\boost_1_35_0\lib".

Friday, April 04, 2008

Wireshark matures; v1 is released

Wireshark, formerly called Ethereal, has made it to the 1.0 milestone. Congrats to Gerald Combs and the team. Wireshark is an amazingly useful application that helps analyse network traffic.

As a software engineer it's an invaluable part of my toolkit and I'm very grateful for the many folks who work on this wonderful open-source (GPL) application.

Internet Sharing: Mac to Windows

Sharing an Internet connection from your Mac is trivially easy:

  • Open System Preferences
  • Choose Sharing
  • Tick the Internet Sharing checkbox

Typically I share out my wired Ethernet connection over wireless (Airport in Mac parlance).


You'll need to configure the Network Name (the SSID) and the encryption settings. Unfortunately WPA is not yet supported so your best bet is 128 bit WEP. You'll also need to choose a 13-character password if you want Windows computers to share your network (if you're network only has Mac's then feel free to choose any length password).


Connecting any Mac to this network is trivial. Simply turn on AirPort, browse to the network and enter the password.

Unfortunately, from a Windows PC it isn't quite so obvious - you can't just auto-detect the network and enter the password. You'll need to perform the following steps:

  • Open Control Panel, Network Connections and click on Wireless Connections
  • Add a new wifi network
  • Enter the Network Name that you created on the Mac - it must match exactly
  • Set the Network Authentication to Shared
  • Set the Data Encryption to WEP
  • Uncheck "The Key is Provided Automatically" and enter the 13-character password that you chose earlier

You should now find that the Windows PC can connect to the network.

If you're using a wifi manager other than the standard Windows functionality then you may need to experiment on the various settings. One manager I had to configure wouldn't work until I chose Enterprise as a network type.

I'll try and get some Windows screenshots soon (my VM doesn't have a wireless connection).

Hope that helps someone!