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

CppDepend

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.