Migration from Visual C++ 6.0 to 2005 – Part II
Continuing my previous article about my struggling with porting some code to VC8.0 this article shows some more of the changes we had to do in order to make our code to compile in both visual C++ 6.0 and 8.0 a.k.a. 2005.
Links:
Migration from Visual C++ 6.0 to 2005 – Part I
Migration from Visual C++ 6.0 to 2005 – Part III
the standard headers are now missing .h
In VC6 this
#include <fstream.h>
#include <iostream.h>
is now in VC2005:
#include <fstream>
#include <iostream>
So we in order to make it compilable by both compilers we did:
#if _MSC_VER && (_MSC_VER > 1200)
#include <fstream>
using namespace std;
#else
#include <fstream.h>
#endif
Redefinition of new operator
Including the standard headers (fstream, iostream, etc.) must be done before (if any) redefining of the operator new.
We had something like the following in one of our header files:
[source:cpp]
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
[/source]
This one took me a while to figure out. In “Release” it compiled, but in “Debug” it complained about new redefinition in xdebug… Very annoying.
CString is now a template class CStringT
We had in one of our legacy header file a forward declaration class CString and it took me a while to figure out what’s wrong, but the change was just removing the declaration and all seemed to have worked.
DLL and Library Incompatibility
Unfortunately DLLs and static libraries must be rebuilt, if they use MFC or ATL and have exported functions that take MFC or ATL related parameters or return values.
CException is now abstract
If CException have been instanciated directly, this is a breaking change now, because it is now an abstract class.