Monday, June 06, 2011

Coding Font

I'm setting up a new work computer today. 8 cores, 8 GB RAM (nice).

I needed to download my favorite font for Visual Studio. I like Coding Font Tobi, which can be found here:

Monday, August 16, 2010

Create Windows XP Pro SP3 OEM Install CD

How to create a Windows XP Pro SP3 OEM install CD with IE8 and many of the latest security updates.

1. Grab a valid Windows install CD. In my case, a OEM install CD since I wanted to use the COA sticker product id on the computer box. The OEM stickers all were Windows XP Pro on Dell computers. You can use an existing Dell Windows XP Pro CD, or contact Dell for one, or download one (not sure if the downloaded CDs are legal). See on how to determine what type of windows license key you have.

2. Copy the CD onto your computer for modification.

3. Use nLite to modify the CD and add the components you want. In my case I wanted to add SP3, latest security updates, and IE8.

4. Addons including IE8 can be found here:

5. The latest security updates can be found here: These can be used with the latest nLite, just follow the RyanVM nLite integration instructions on the RyanVM site. Even with these latest security updates, I found that windows still wants to download and install many additional updates. But at least this will be less than it would be without it.

6. Add the IE8 add on from the nLite add on site above. You can add others but be careful to not add more than will fit on a single CD. If you have a DVD drive on your install computer and a DVD burner available then you can add all kinds of additional software from the addon site. You can also integrate the universal drivers if you have room (see below). Since my computers only had CDRom drives, I had to keep it small.

7. One problem with installing Windows is drivers for existing hardware. For example the network card, audio, and video was not setup during the windows install on my Dells. This is particularly frustrating since you can't access the internet to download drivers. However, a very nice solution is to use DriverPacks found here:

7a. Download the driver packs base:

7b. Download all the driver packs for your version of Windows:

7C. Run DriversPack Base. I created a Stand Alone Driver Disk and put it on a usb thumbdrive. This worked amazingly well. After the Windows install I just hooked up the usb thumbdrive and ran DP_Install_Tool.cmd. It takes awhile to run, but when it is finished all hardware had updated drivers and worked without issue. It installed missing audio drivers, network card drivers, and video drivers. It really is quite amazing. You can even run it multiple times. I ran it after throwing a wireless network card in one computer and after adding a usb wireless adapter in another, in both cases it installed the needed drivers. I plan on keeping it around for those cases where you have a network card, video card, usb wireless adapter, etc but don't have the driver cd. It is easier than trying to find the correct driver on the web.

8. Create a installer for all the free applications you want installed using Ninite. This is nice because it creates a click free install for as many applications as you want. The only drawback is the free version requires each computer to download the applications. However, you can kick it off and forget about it, so not a big deal. The installer can be included on the Windows XP CD by just putting it in the directory before creating the ISO image using nLite or just throw it on a usb thumbdrive. The installer is small since it downloads all the applications from the web. If the install fails for some reason (in my case unplugging the network switch during the install), then just go the ninite site and create another installer for the pieces that did not install. Or just kick off the full install again.

Tuesday, June 08, 2010

Visual Studio 2008 IntelliSense Tips

Recently started working with Visual Studio 2008 again. Unfortunately my current project is restricted to 2008 and we can't yet upgrade to Visual Studio 2010.

Visual Studio 2008's C++ IntelliSense is a big improvement over Visual Studio 2005, however at times I find it still has difficulties showing popup info and going to definition. If you search for these types of problems you find many people advising deleting *.ncb and rebuilding. After some trial and errors and hints from Microsoft sites about potential parser problems, I can offer the following advice which has worked great for me for solving these types of issues.

If the "Go To Definition" goes to the declaration instead of the method definition, then make sure the declaration does not use any immediately undeclared types. By immediate I mean in the header file itself. Pre-compiled headers do not seem to count.

For example:

void foo(const string& str, ostream& os);
// should be:
void foo(const std::string& str, std::ostream& os);

// make sure A is forward declared, or included
void foo(const A& a);

// make sure Temp and A are forward declared,
// class A;
// template <class X> class Temp;
void foo(Temp<A>& t);

Thursday, April 10, 2008

C++ array size determination - Part 2

In my last post I showed how to create a template function to determine the size of a C++ array and promised to show how to create a template that will work with a type instead of a variable.

Lets start by looking at a struct template that through specialization we can use to capture the number of elements in an array.
  template <typename T>
struct array_info
This just names a template that we will specialize for arrays, like so:
  template <typename T, size_t N>
struct array_info<T[N]>
typedef T type;
enum { size = N };
Now we have a template that for arrays will enable us to get to the size and type of elements in the array. This can be used like so:
  typedef int IntArray[10];
size_t s = array_info<IntArray>::size; // s == 10
Or like so:
  float floatArray[array_info<IntArray>::size];
If we try something other than an array we get a compiler error.
  size_t s = array_info<int*>::size; // error
Generates a compiler error similar to:
  error: 'size' is not a member of '<unnamed>::array_info<int*>'
This is nice, but the real power is in using this with other templates. Even though I'm working with arrays one of the apis I'm using returns a pointer instead of an array reference. I know the type (which includes its length) so I wanted to take advantage of that. Here I use the array_info in an equal method to determine the length:
  template <typename A, typename T>
bool equal(const T* lhs, const T* rhs)
// Use 'typename array_info<A>::type' instead of 'T' so that compiler
// verifies A and T types match up.
const typename array_info<A>::type* const end = &lhs[array_info<A>::size];
return std::equal(&lhs[0], end, rhs, &equal_to<T>);
This template can then be used like so:
  equal<IntArray>(lhs.getVal(), rhs.getVal());
That is not syntax you get to use everyday.

C++ array size determination

My current project has me working with C-style C++ arrays. In order to make things easier and safer I created some helper templates.

Lets start with finding the the number of elements in an array. The conventional C way would be to use sizeof like:
I'm not a big fan of this approach. I have seen production code by seasoned C++ developers that looks like this:
  const char* tmp = 0;
// ...
int size = sizeof(tmp)/sizeof(tmp[0]);
Of course this is sometimes hidden behind a macro:
  #define array_size(array) (sizeof(array)/sizeof(array[0]))
// ...
int size = array_size(tmp);
Either way, this gives the wrong answer. The developer, of course, is not interested in what the size of a pointer to an element divided by the size of an element is.

So, can we do better? Actually, yes, we can.
  template <typename T, size_t N>
size_t array_size(const T (&lhs)[N])
return N;
Here we pass an array by reference to array_size() that extracts the size of the array and returns it. I talked briefly about array passing a few years ago.

We can now use it like so:
  int ia[10];
size_t s = array_size(ia); // s == 10
And if we try to use this with a pointer like so:
  const char* tmp = 0;
// ...
size_t s = array_size(tmp); // error
We get a compiler error similar to:
  error: no matching function for call to 'array_size(const char*&)'
Very nice.

However, sizeof can also be used with a type instead of a variable. In my next post, I'll show how we can create a template that will work with a type instead of a variable.

Wednesday, April 02, 2008


I'm speaking on Boost.Thread this year at BoostCon'08.

Here is the announcement from the Boost mailing list:

Reminder: early registration for BoostCon'08 closes Monday, April 7.
It's still not too late to avoid the late registration fee for what may
be the finest C++ event of 2008.

For the 2nd annual Boost C++ libraries conference, we've put together a
fantastic program crowned by a keynote address from Bjarne Stroustrup.
In addition to existing Boost libraries, we're covering technology of
interest to any C++ developer trying to stay on the cutting edge,
including hands-on sessions with features from the upcoming 2nd version
of the C++ standard. This year we've also added a collection of short
"author's corner" sessions for those of you who want an inside
perspective on how advanced libraries are developed. See for details.

BoostCon 2008 will be hosted at Aspen Center for Physics, one of the
most beautiful meeting sites in the world, and a great venue for
collaboration and discovery. The combination of a relaxed pace and
intense inquiry made BoostCon'07 an event to remember, and we expect no
less for this year. Please visit
to register.


-- The BoostCon Planning Committee

David Abrahams
Beman Dawes
Jeff Garland
Joel de Guzman
Eric Niebler
Sean Parent
Jeremy Siek
Matthias Troyer

Monday, March 31, 2008

Building Boost 1.35.0

Seems I always have troubles building Boost.

To start I followed the big 'Get Boost' button on the right side of; thinking, 'That sure is obvious'. That link takes you to a download page with boost version 1.35.0 right at the top. It shows the new libs with 'Detail' and 'Download'. I took a few seconds to read the new libs section and clicked on download. This took me to where they have the source code only release. Well, I knew that Boost Consulting has maintained an installer for Windows assuming you are using boost with Visual Studio. So I jumped over to their boost installer site, only to find that they don't have one yet for 1.35.0.

No problem, I'll just go back and grab the source code from and follow the instructions in the getting started document. I kicked off the download and started looking for the getting started document. After a while, I figure I must be crazy, because I can't find it. I finally do a google search in order to find it. Still thinking I must have just missed it, I went back and followed every link on the right of the the main boost site. It is not under 'Introduction' or any other of the sections. I finally did locate it, it is on the main page on the left under 'GETTING STARTED'. Funny how you can look right past something like that.

So now I figure all I have to do is follow the getting started guide to build boost.

Step 1. Get Boost. I already did that. My download had already completed from I unziped it (actually un-7zed it) to c:\boost\boost_1_35_0\.

Step 2. Explain Boost Distribution. Ok, nothing new here.

Step 3. Header only libs. Right, header only libs are nice. Just compile and go. However, Boost.Thread among others need to be compiled.

Step 4. Build with a header only lib. Been there done that many times. There are sub-steps for building with Visual Studio. I always use MPC, so this is not useful to me. I plan to create a separate post or two about building boost applications with MPC. When you see how easy it is to use MPC with Boost, I doubt that you will use anything else.

Step 5. Building Boost libraries. Alright, here we go.

Step 5.1. Install Boost libraries. Yeah, thats what I wanted to do to start with. However, Boost Consulting has not yet put out an installer for 1.35.0.

Step 5.2. Build from source.

Step 5.2.1. Get bjam. I put the executable in c:\boost\boost_1_35_0\.

Step 5.2.2. Identify toolset. I want: msvc.

Step 5.2.3. Select a build directory. It says this is not necessary.

Step 5.2.4. Invoke bjam. This is where I got in trouble. I tried various combinations of commands/arguments to bjam. I must have tried to build 3-4 times. Finally I settled on the following after looking at bjam --help.
cd c:\boost\boost_1_35_0
bjam --build-type=complete --prefix="c:\boost\boost_1_35_0" install
Seems like I should have included --toolset=msvc, but I forgot and it picked msvc-8.0 anyway.

This worked for me creating a c:\boost\boost_1_35_0\lib directory as the rest of the getting started document assumes. Actually the getting started doc has it under C:\Program Files\boost\boost_1_35_0\lib, but I like c:\boost\boost_1_35_0\lib better.

After the build you can delete the c:\boost\boost_1_35_0\bin.v2 directory to free up space.