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. What is wrong with the stupid VC 2005?

What is wrong with the stupid VC 2005?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
7 Posts 7 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.
  • I Offline
    I Offline
    includeh10
    wrote on last edited by
    #1

    I have to move from VC6 to VC2005. here is some error code: //--------------------------- i_Random is int i_Random%=10; CString cs24; cs24.Format("%d",i_Random); //--------------------------- VC 2005 compiler says that last line above has error: error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [3]' to 'const wchar_t *' with [ BaseType=wchar_t, StringTraits=StrTraitMFC_DLL<wchar_t> Do you know what the stupid VC2005 want to do?

    M S C C A 6 Replies Last reply
    0
    • I includeh10

      I have to move from VC6 to VC2005. here is some error code: //--------------------------- i_Random is int i_Random%=10; CString cs24; cs24.Format("%d",i_Random); //--------------------------- VC 2005 compiler says that last line above has error: error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [3]' to 'const wchar_t *' with [ BaseType=wchar_t, StringTraits=StrTraitMFC_DLL<wchar_t> Do you know what the stupid VC2005 want to do?

      M Offline
      M Offline
      Mohammad Akbar
      wrote on last edited by
      #2

      Your VS2005 defaults to unicode. "%d" is of type char but CString.Format needs a unicode format string. you can modify your code as following : cs24.format(L"%d",i_Random); or cs24.format(TEXT("%d"),i_Random); however please pay attention that this may not be the only place in your code you have to check against unicode (wchar_t) compatibility. cheers. Mohammad

      1 Reply Last reply
      0
      • I includeh10

        I have to move from VC6 to VC2005. here is some error code: //--------------------------- i_Random is int i_Random%=10; CString cs24; cs24.Format("%d",i_Random); //--------------------------- VC 2005 compiler says that last line above has error: error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [3]' to 'const wchar_t *' with [ BaseType=wchar_t, StringTraits=StrTraitMFC_DLL<wchar_t> Do you know what the stupid VC2005 want to do?

        S Offline
        S Offline
        SandipG
        wrote on last edited by
        #3

        Remove _UNICODE from project settings.

        1 Reply Last reply
        0
        • I includeh10

          I have to move from VC6 to VC2005. here is some error code: //--------------------------- i_Random is int i_Random%=10; CString cs24; cs24.Format("%d",i_Random); //--------------------------- VC 2005 compiler says that last line above has error: error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [3]' to 'const wchar_t *' with [ BaseType=wchar_t, StringTraits=StrTraitMFC_DLL<wchar_t> Do you know what the stupid VC2005 want to do?

          C Offline
          C Offline
          Cedric Moonen
          wrote on last edited by
          #4

          To complete the previous answers: here[^] is a complete article about the subject. I suggest you take a look at it, you will learn a lot of usefull things.

          Cédric Moonen Software developer
          Charting control [v1.4]

          1 Reply Last reply
          0
          • I includeh10

            I have to move from VC6 to VC2005. here is some error code: //--------------------------- i_Random is int i_Random%=10; CString cs24; cs24.Format("%d",i_Random); //--------------------------- VC 2005 compiler says that last line above has error: error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [3]' to 'const wchar_t *' with [ BaseType=wchar_t, StringTraits=StrTraitMFC_DLL<wchar_t> Do you know what the stupid VC2005 want to do?

            C Offline
            C Offline
            CPallini
            wrote on last edited by
            #5

            Well, VC2005 is not stupid, hence... :-D

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

            1 Reply Last reply
            0
            • I includeh10

              I have to move from VC6 to VC2005. here is some error code: //--------------------------- i_Random is int i_Random%=10; CString cs24; cs24.Format("%d",i_Random); //--------------------------- VC 2005 compiler says that last line above has error: error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [3]' to 'const wchar_t *' with [ BaseType=wchar_t, StringTraits=StrTraitMFC_DLL<wchar_t> Do you know what the stupid VC2005 want to do?

              A Offline
              A Offline
              Ahmed Charfeddine
              wrote on last edited by
              #6

              Why do you use the term stupid when you risk to be the one who is stupid ? And there are many people here like me who will not accept such langage and the least they can do, they will let you with you problem without helping you. OK now, use the following macro without the need to change the charSet property of your project : _T ==> cs24.Format(_T("%d"),i_Random); always take the habit of using it, even when you have a nonUnicode charSet.

              1 Reply Last reply
              0
              • I includeh10

                I have to move from VC6 to VC2005. here is some error code: //--------------------------- i_Random is int i_Random%=10; CString cs24; cs24.Format("%d",i_Random); //--------------------------- VC 2005 compiler says that last line above has error: error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [3]' to 'const wchar_t *' with [ BaseType=wchar_t, StringTraits=StrTraitMFC_DLL<wchar_t> Do you know what the stupid VC2005 want to do?

                T Offline
                T Offline
                toxcct
                wrote on last edited by
                #7

                includeh10 wrote:

                What is wrong with the stupid VC 2005?

                before saying so, you'd better: 1) searched the forum; it's been said tons of times already that VC6 defaults to ANSI when VS2005 defaults to UNICODE builds. 2) asked "what's wrong with the stupid VC6 ?". because, yes, VC6 is far less standard compliant that VS2005, hence it accepts mistakes without complaining, when VS2005 now will tell you YOU made an error. 3) understood you development environment before incriminiate a tools which only does what you tell it to do.

                [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                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