Friday, August 10, 2007

Porting legacy codes to Visual Studio 2005

Lately we were given a code base from EA. It was a mixture of C and C++ codes. They continously added code to it on demand in an adhoc basis for the last 14 years. Our task is to develope the same tool from scratch if need be we can use some of their codes as well. And the requirement is the tool needs to be developed in Microsoft Visual Studio 2005. So our first task was to build the existing legacy code they dumped us with in 2005. While trying to do so I faced a few issues which I want to share in this post :

Commmon Problem 1:
error C2220: warning treated as error - no 'object' file generated
warning C4996: 'wcstombs' was declared deprecated
c:\program files\microsoft visual studio 8\vc\include\stdlib.h(562) : see declaration of 'wcstombs'
Message: 'This function or variable may be unsafe. Consider using wcstombs_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'

Solution -
#pragma warning ( disable : 4996 )
Commmon Problem 2:
error C2440: 'initializing' : cannot convert from 'const char *' to 'char *'

The code was :
char *pTxdGroupXml = strstr(name, "_resources.xml");

Solution -
Change the code to :
char *pTxdGroupXml = (char*) strstr(name, "_resources.xml");
Common Problem 3
error C3861: '_assert': identifier not found

#define _assert(exp, fileName, lineNumber) assert(exp)
Common Problem 4
error LNK2005: __configthreadlocale already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
ProjectSettings - > Linker - > Input -> Ignore specific Library : LIBCMTD.lib

Hope this post helps when you are down and fighting to build a mamoth Legacy Code.

- Reza

No comments: