Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2005

Tip: Looking for answers? Try searching our database.

Conversion of 6.0 project to VS 2003

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SteveK - 11 May 2005 22:25 GMT
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.
Tamas Demjen - 12 May 2005 01:57 GMT
> 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
SteveK - 12 May 2005 14:50 GMT
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

>> Why is TCHAR being defined as wchar_t in the VS 2003 project?
>
[quoted text clipped - 4 lines]
>
> Tom
Olaf Baeyens - 12 May 2005 10:58 GMT
>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.  


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.