Share via


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.

Comments

  • Anonymous
    December 14, 2005
    For VC++6 RTM, you can always point out that the compiler DOES conform to every version of the ISO C++ standard that had been approved before VC++6 was released. You can't say the same about the service packs, but it still puts things in perspective.

    Since there was an established C standard at the time, we can even take a second look at this:
    > const x = 0;
    > // won't compile, "int" no longer assumed

    If I recall correctly, the first C standard did still assume int (though deprecated) and C compilers were required to accept it (preferably with warnings). The second C standard, along with the C++ standard, wasn't approved yet when VC++6 was released.
  • Anonymous
    December 15, 2005
    Trying to see if it's the number of links in my previous comments that prevent them from getting posted.
  • Anonymous
    December 15, 2005
    Ok, so it was the spam filtering that blocked those posts.

    Anyway, here's the link I was trying to post (blog entry on VC6 to 2005 porting)

    http://blog.voidnish.com/?p=91

    Change 91 to 90, 89 and 88 for the other posts