Migrating from VC6

I'm back in Redmond today after spending a few days in Dallas for the VC++ Accelerator Lab.  Thanks to all that attended! The lab was a great success, with most attendees completing their port to VC++ 2005 or leaving with only minor issues to resolve.  A lot of our customers are moving to Visual C++ 2005 from Visual C++ 6.  One of the more entertaining aspects of this migration is to see some of the code constructs that VC6 was willing to compile.  Let's just say that VC6 was pretty liberal regarding the content of text files that it would be willing to render to binary code.  It's not uncommon at these labs to hear a customer say, "hey, VC2005 won't compile this, but VC6 has been compiling this code for years!" and then to have a little deeper inspection reveal that the code is actually syntactically incorrect.  Good times.  Of course, there are also the more legitimate instances where formerly valid code constructs no longer conform to the more strict standards enforcement of the VC2005 compiler.  Among the most common of these issues are things like:

For loop variable scope
This code no longer compiles:

for (int i=0; i<10; i++)
{
// do stuff
}
// usage of i here illegal

Need to move the declaration outside of the for loop...

int i;
for (i=0; i<10; i++)
{
// do stuff
}
// usage of i here now okay

Implicit int type

const x = 0; // won't compile, "int" no longer assumed

needs to become:

const int x = 0;

Dot h
Usage of standard headers like this:

#include <iostream.h>
#include <fstream.h>

needs to change to:

#include <iostream>
#include <fstream>
using namespace std;

A mangle by any other name...
It's also common for applications to rely on external libraries or OBJs built with earlier compilers.  These LIBs and OBJs will often fail to link with VC 2005-compiled code due to changes in name mangling conventions (although it will sometimes work if everything was declared 'extern "C"').  In general, you'll want to rebuild those libraries or obtain version from the respective vendors built with VC 2005.