Monday, January 28, 2008

Migrating VC++ code from VS2003 to VS2005 to VS2008

VS2005
The best reference for Migrating to VS2005 is available at MSDN.

http://msdn2.microsoft.com/en-us/library/ms177253(VS.80).aspx

Some additional issues I faced during conversion are documented below:
Resource.h file missing:
For some stupid reason Microsoft keeps moving around the include directories, making the paths incompatible. If you intend to use the "Resource.h" file in your projects and the compiler complains that it cannot find the file, simply do the following:
1) Use the string "$(VCInstallDir)atlmfc\src\atl"
2) Add it under Properties->Resources->General->Additional Include Directories.
This should fix the issues.

VS2008
SOCKADDR_STORAGE:
This function definition was moved to "Ws2def.h" instead of "Winsock2.h" for VS2008. Also the function was renamed to SOCKADDR_STORAGE_XP. The work around is to include the "Ws2def.h" fine. Also define a preprocessor of the form _VS2008 (if you don't want to rename the structure everywhere in the code). And add a code snippet of the form

#ifdef _VS2008
#define SOCKADDR_STORAGE SOCKADDR_STORAGE_XP
#endif

This ensures that your solution works for both VS2008 and VS2005 or before. If you don't care about previous versions anymore, just skip the #ifdef and just use the #define part. Also please make sure _WIN32_WINNT is set to the right value (0x0501 or higher).

I will keep updating this post for more issues as I face and fix them.

No comments: