Draznar

I am tasked with the job of porting several codebases that work in 6.0 to make them work in 2005, while still working in 6.0. The projects need to compile on both versions. As a solution to this (nightmare) problem, I have been told that the best way to do this is alot of #if and #endif statements all througout the code. 99% of all the errors or problem come from ifstream or ofstream. Includes have been set up as such in various places of the code. (To me it feels like somewhat of a hack job)

Code Snippet

#define MSC_VER 1400

#if MSC_VER > 1300

#include <fstream>

#else

#include <fstream.h>

#endif

Code Snippet

#if MSC_VER > 1300

std::ifstream PreferencesFile;

#else

ifstream PreferencesFile;

#endif

More or less, everything seems to work, if we type in that "#define MSC_VER 1400". But thats just a temp fix and it can not stay there in the actual file. I am trying to add this into the preprocessor definitions so the same code will work in 6.0 and in VS 2005. I go into the project properties, go to the C/C++ tab and go down to preprocessor and then into preprocessor definitions. I've tried adding MSC_VER, MSC_VER = 1400, MSC_VER 1400. Nothing seems to work, am I going about this the wrong way What must I do to make this work or is there maybe a better solution to accomplish this



Re: Visual C++ Language Moving VC++6.0 to VC++8.0 - Preprocessor Problem?

einaros

Use

Code Snippet

whatever's-already-in-the-definition-list;"MSC_VER=1500"






Re: Visual C++ Language Moving VC++6.0 to VC++8.0 - Preprocessor Problem?

Sdi

WRT "am I going about this the wrong way ", if you're trying to make the code sensitive to which version of the compiler being used, but then turning around and lying to the code about the version of the compiler being used, I'd say that the answer is "yes". Why do you want to mislead the code about the compiler version

Stepping back a bit, what errors did you get when you took the code that compiled under VC6 and tried to compile it--unmodified--under VS2005 Somehow it seems unlikely that MS would have made that much of a backward-compatibility break, especially in areas controlled by the standard headers.