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::Format - Debug vs Release

CString::Format - Debug vs Release

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiodebugginghelpquestionannouncement
8 Posts 5 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.
  • D Offline
    D Offline
    Dustin Henry
    wrote on last edited by
    #1

    I have a program that uses at least 50 calls to the CString::Format function. The problem comes when I change from Debug to Release mode and try to compile. In Release mode, the function expects a 'const wchar_t *' and in Debug a 'const char *'. I know that you can use the 'L' macro to make a literal string a 'const wchar_t *', but then it doesn't work when I switch back to Debug. Is there a way to get around this or do I just have to save my release compilation until the very end and add the 'L' macro to all of these functions? Also, does anybody know the reason Microsoft did this? Thanks, Dustin

    K C M 3 Replies Last reply
    0
    • D Dustin Henry

      I have a program that uses at least 50 calls to the CString::Format function. The problem comes when I change from Debug to Release mode and try to compile. In Release mode, the function expects a 'const wchar_t *' and in Debug a 'const char *'. I know that you can use the 'L' macro to make a literal string a 'const wchar_t *', but then it doesn't work when I switch back to Debug. Is there a way to get around this or do I just have to save my release compilation until the very end and add the 'L' macro to all of these functions? Also, does anybody know the reason Microsoft did this? Thanks, Dustin

      K Offline
      K Offline
      kakan
      wrote on last edited by
      #2

      Could it be that the release build is unicode, and debug build isn't?

      Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson

      D 1 Reply Last reply
      0
      • D Dustin Henry

        I have a program that uses at least 50 calls to the CString::Format function. The problem comes when I change from Debug to Release mode and try to compile. In Release mode, the function expects a 'const wchar_t *' and in Debug a 'const char *'. I know that you can use the 'L' macro to make a literal string a 'const wchar_t *', but then it doesn't work when I switch back to Debug. Is there a way to get around this or do I just have to save my release compilation until the very end and add the 'L' macro to all of these functions? Also, does anybody know the reason Microsoft did this? Thanks, Dustin

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

        Debug vs Release or Debug vs RELEASE UNICODE?

        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.

        D 1 Reply Last reply
        0
        • K kakan

          Could it be that the release build is unicode, and debug build isn't?

          Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson

          D Offline
          D Offline
          Dustin Henry
          wrote on last edited by
          #4

          Good call. That fixed it. I didn't even think about checking that. You're the man.

          K 1 Reply Last reply
          0
          • C CPallini

            Debug vs Release or Debug vs RELEASE UNICODE?

            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.

            D Offline
            D Offline
            Dustin Henry
            wrote on last edited by
            #5

            I love this board. 2 helpful answers in under 10 minutes.

            1 Reply Last reply
            0
            • D Dustin Henry

              Good call. That fixed it. I didn't even think about checking that. You're the man.

              K Offline
              K Offline
              kakan
              wrote on last edited by
              #6

              :cool: Thanks.

              Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson

              1 Reply Last reply
              0
              • D Dustin Henry

                I have a program that uses at least 50 calls to the CString::Format function. The problem comes when I change from Debug to Release mode and try to compile. In Release mode, the function expects a 'const wchar_t *' and in Debug a 'const char *'. I know that you can use the 'L' macro to make a literal string a 'const wchar_t *', but then it doesn't work when I switch back to Debug. Is there a way to get around this or do I just have to save my release compilation until the very end and add the 'L' macro to all of these functions? Also, does anybody know the reason Microsoft did this? Thanks, Dustin

                M Offline
                M Offline
                Mike ONeill
                wrote on last edited by
                #7

                For all string literals in your code, you should use the _T("xxx") macro. For unicode builds, _T() is replaced by 'L', whereas for non-unicode builds it gets replaced by white space. So, literals end up correctly defined automatically, regardless of the build. Mike

                D 1 Reply Last reply
                0
                • M Mike ONeill

                  For all string literals in your code, you should use the _T("xxx") macro. For unicode builds, _T() is replaced by 'L', whereas for non-unicode builds it gets replaced by white space. So, literals end up correctly defined automatically, regardless of the build. Mike

                  D Offline
                  D Offline
                  d34studios
                  wrote on last edited by
                  #8

                  Thanks for the advice.

                  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