CString issue after upgrading to VS2005 (not using _T)
-
Hi All I have miles of old code that looks like this: CString csString = "hello World"; Having just installed VS2005, I get the error: 'initializing' : cannot convert from 'const char [3]' to 'ATL::CStringT I know that I can get around this like this: CString csString = _T("Hello World"); But want to know if there is a single switch somewhere that will let my code compile as it was? I also don't understand why it's using ATL and not MFC - I craeted a new MFC project Many thanks for any help offered
-
Hi All I have miles of old code that looks like this: CString csString = "hello World"; Having just installed VS2005, I get the error: 'initializing' : cannot convert from 'const char [3]' to 'ATL::CStringT I know that I can get around this like this: CString csString = _T("Hello World"); But want to know if there is a single switch somewhere that will let my code compile as it was? I also don't understand why it's using ATL and not MFC - I craeted a new MFC project Many thanks for any help offered
John Strudwick wrote:
if there is a single switch somewhere that will let my code compile as it was?
Possibly; it sounds like you're set up for a UNICODE build. Take a look at your stdafx.h file. If the symbol
UNICODE
is#define
'd, try commenting it out and rebuilding the solution.John Strudwick wrote:
I also don't understand why it's using ATL and not MFC - I craeted a new MFC project
Back in MFC 7.0 (Visual Studio 2002) they switched from separate
CString
implementations within ATL and MFC to a single, common implementation. As part of that, they improved the type-safety of the various constructors and assignment operators.
Software Zen:
delete this;
-
John Strudwick wrote:
if there is a single switch somewhere that will let my code compile as it was?
Possibly; it sounds like you're set up for a UNICODE build. Take a look at your stdafx.h file. If the symbol
UNICODE
is#define
'd, try commenting it out and rebuilding the solution.John Strudwick wrote:
I also don't understand why it's using ATL and not MFC - I craeted a new MFC project
Back in MFC 7.0 (Visual Studio 2002) they switched from separate
CString
implementations within ATL and MFC to a single, common implementation. As part of that, they improved the type-safety of the various constructors and assignment operators.
Software Zen:
delete this;
Thanks Gary - that has solved the problem I went into the properties dialog and changed from unicode to not set - works a treat Thanks again
-
Thanks Gary - that has solved the problem I went into the properties dialog and changed from unicode to not set - works a treat Thanks again
You're welcome. I believe I remember reading that the wizards in VS2005 changed from a default of building ANSI applications to UNICODE. Believe it or not, there are advantages to building apps as UNICODE. They are much easier to translate to other languages (which may not be a concern for you). They also have something of a performance advantage. Windows itself uses UNICODE. With ANSI applications, there is an implicit conversion from ANSI strings to UNICODE with strings you pass to Windows, and the reverse when Windows returns strings to you.
Software Zen:
delete this;