Conversion of 6.0 project to VS 2003

S

SteveK

We have just started converting a large project from VisualStudio 6.0 to VisualStudio 2003. Of course, we're encountering some problems.

The first of which involves some CString() constructors not taking arguments that were valid in the 6.0 builds.

As a test, a created a simple 2003 project and inserted the following six lines of code in the stdafx.cpp file:


#include "stdafx.h"

TCHAR x = 't';
CString s(x);

UCHAR uc = 'u';
CString s2(uc);

WCHAR wc = 'w';
CString s3(wc);


and I get the following compiler error:

c:\Temp\TestDotNet2003\TestDotNet2003\stdafx.cpp(15): error C2668: 'ATL::CStringT<BaseType,StringTraits>::__ctor' : ambiguous call to overloaded function
with
[
BaseType=char,
StringTraits=StrTraitMFC_DLL<char>
]
and
[
BaseType=char,
StringTraits=StrTraitMFC_DLL<char>
]






If I try the same thing with the 6.0 compiler, I get the following results:

c:\documents and settings\stevek\my documents\shamrockii_1_0\stdafx.cpp(27) : warning C4244: 'argument' : conversion from 'unsigned short' to 'char', possible loss of data


WCHAR wc = 'w';
CString s3(wc); // offending line

If in the Stdafx.cpp file of the 2003 project, I right-click on CString and select the "Go To Definition", I goto line 103 of afxstr.h

typedef ATL::CStringT< TCHAR, StrTraitMFC< TCHAR > > CString;

and then if I again right-click on TCHAR and select "Go To Definition", I get to line 141 of tchar.h

#ifndef _TCHAR_DEFINED
#if !__STDC__
typedef wchar_t TCHAR; // line 141
#endif
#define _TCHAR_DEFINED
#endif


it appears that TCHAR has a typedef of wchar_t.



If I following the same steps ("Go To Definition") I get to:

#ifndef _TCHAR_DEFINED
typedef char TCHAR, *PTCHAR; // line 324 of WinNT.h
typedef unsigned char TBYTE , *PTBYTE ;
#define _TCHAR_DEFINED
#endif /* !_TCHAR_DEFINED */



Why is TCHAR being defined as wchar_t in the VS 2003 project?



Does anyone have a list of common problems and tips we could follow while in the process of converting a large project.



Any help would be appreciated.
 
T

Tamas Demjen

SteveK said:
Why is TCHAR being defined as wchar_t in the VS 2003 project?

TCHAR is either char or wchar_t, depending whether the project is MBCS
or Unicode. Go to the project's configuration properties, General,
Character Set, and set it to Use Multi-Byte Character Set if you don't
want Unicode. If you do want Unicode, you have to accept that TCHAR is
wchar_t.

Tom
 
O

Olaf Baeyens

have a list of common problems and tips we could follow while in the process of converting a large project.In the case of mathimatical functions you should typecast to float/double.
For the rest nothing much different compared to VC++ 6.0

Just make sure that you have a backup, because you cannot go back to VC++ 6.0. It is a one way transition.
 
S

SteveK

Tom,

I already had "Use Mult-Byte Character Set" selected. Can you think of
anywhere else this could be comming from? That is TCHAR getting defined
wchar_t?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top