Thursday, May 01, 2008

Convert VC++6 to VC++7 -- (1)

VC++6 is a pretty solid product, which can still produce decent software in Windows XP. But Microsoft has decided to stop support for VC6 for about 2 years now. With the arrival of VS2008 and Windows Vista, it might finally be the time to convert those old projects that you still want to keep alive into a newer platform.

To start the conversion is really easy, just open the .dsp file in Visual Studio 2003. It will convert the project for you automatically, and generate the .vcproj and .sln files. If you are lucky, the next step is press F7 to build the solution and press F5 to run it, and you are done. Unfortunately, 90% of us will need to change the code to make it even compile. VC++6 is less standard compliant than VC++7 and there are some other breaking changes in VC++7.

This series will report problems I've seen when I convert a VC++6 project to VC++7 and some tips to help smooth the process.

Tip 1: for a project that is still actively maintained, during the conversion care must be taken so that changes do not break the software under VC++6. Use this to allow the code changes exists peacefully in VC++6:

#if _MSC_VER >=1500
//this is VC++9.0 or above
#elif _MSC_VER >= 1400
// this is VC++8.0
#elif _MSC_VER >= 1310
// this is VC++7.1
#elif _MSC_VER > 1300
// this is VC++7.0
#else
//assume VC++6
#endif

No comments: