Migrating from 6.0 to .NET
Hi,
I'm investigating how easy/difficult it will be to migrate from Visual C++ v6.0 to .NET.
I tried simply rebuilding one of our projects without modification, but got the WINVER problem. So I fixed that, then tried to build again...
This time, I got CString errors.
I looked up the HELP, and found Q309801 "PRB: Linking Errors When You Import CString-Derived Classes" (http://support.microsoft.com/default...;EN-US;Q309801). This suggests adding the following 2 lines to stdafx.h :-
template class __declspec(dllimport) CStringT<TCHAR, StrTraitMFC<TCHAR, ChTraitsCRT<TCHAR> > >;
template class __declspec(dllimport) CSimpleStringT<TCHAR>;
I added these lines, but I am still getting loads of CString errors in the build, e.g. :-
PeriodEdit.cpp(25) : error C2079: 'CScanString::MyString' uses undefined class 'CString'
(code is - "class CScanString : public CString")
I have looked for ages trying to find related threads with a solution. However, a lot of the relevant threads have been left hanging without a solution.
Does anyone know how to solve this CString problem?
(Is this the right forum for this question?)
Re: Migrating from 6.0 to .NET
Completely off the top of my head...'CString' is now a template class...thus...the following should work (hope I get it right)...
Code:
class CScanString : public CStringT<TCHAR, StrTraitMFC<TCHAR> >
Re: Migrating from 6.0 to .NET
Andreas,
Thanks for your help.
That fixed the particular problem in the declaration.
However, now I get a failure a bit further down...
class CScanString : public CStringT<TCHAR, StrTraitMFC<TCHAR> >
{
friend class CString;
private:
CString MyString;
PeriodEdit.cpp(27) : error C2079: 'CScanString::MyString' uses undefined class 'CString'
It looks like I am going to have to do a lot of work getting our code to compile, as we use CStrings everywhere.
Has anyone else had this problem? I wouldn't have thought we are the first to hit this problem...
Re: Migrating from 6.0 to .NET
Well...you can of course 'typedef' around the problem...however, that seems to a little bit too much work...I actually do not have any .NET compiler installed somewhere (my annual Christmas installing party is coming up :cool: ), thus, I cannot try it for myself....sorry for that...
Re: Migrating from 6.0 to .NET
I've got the same errors (error C2027: use of undefined type 'CString'). What i don't understand is that i have a lot of application in VC++ 2003 that works fine using CString and my current project has lots of errors. Please let me know if you find a solution for this.
Re: Migrating from 6.0 to .NET
zc0styn,
My problem was a "friend" declaration, described as follows :-
"friend class not required when derived from class"
Here is an example of a class derived from CString, but containing a redundant friend class CString :-
class CScanString : public CString
{
friend class CString;
private:
CString MyString;
const char *StartOfString;
public:
int ReadFloatNums(float**, char *);
int ReadPercentages(float**, char *);
const CScanString& operator=(const CString& stringSrc);
};
Trying to compile this in .NET gives error :-
error C2079: 'CScanString::MyString' uses undefined class 'CString'
Since the CScanString class is already based on CString, the friend declaration is redundant, and should be removed.