Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CString issue after upgrading to VS2005 (not using _T)

CString issue after upgrading to VS2005 (not using _T)

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++question
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    John Strudwick
    wrote on last edited by
    #1

    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

    G 1 Reply Last reply
    0
    • J John Strudwick

      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

      G Offline
      G Offline
      Gary R Wheeler
      wrote on last edited by
      #2

      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;

      Fold With Us![^]

      J 1 Reply Last reply
      0
      • G Gary R Wheeler

        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;

        Fold With Us![^]

        J Offline
        J Offline
        John Strudwick
        wrote on last edited by
        #3

        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

        G 1 Reply Last reply
        0
        • J John Strudwick

          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

          G Offline
          G Offline
          Gary R Wheeler
          wrote on last edited by
          #4

          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;

          Fold With Us![^]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups