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. Some code of VC++

Some code of VC++

Scheduled Pinned Locked Moved C / C++ / MFC
c++debuggingquestion
5 Posts 4 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.
  • T Offline
    T Offline
    tyagineha
    wrote on last edited by
    #1

    What does the following code do????????? #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif NT

    C M 2 Replies Last reply
    0
    • T tyagineha

      What does the following code do????????? #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif NT

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      if _DEBUG has been defined elsewhre, it defeines DEBUG_NEW and undefines THIS_FILE, then sets it to the current file namae. It's not C++, it's nasty C preprocessor stuff. Avoid if you can.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      C M 2 Replies Last reply
      0
      • C Christian Graus

        if _DEBUG has been defined elsewhre, it defeines DEBUG_NEW and undefines THIS_FILE, then sets it to the current file namae. It's not C++, it's nasty C preprocessor stuff. Avoid if you can.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

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

        Hence he has also to avoid the MFC Application Wizard! :-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.

        1 Reply Last reply
        0
        • C Christian Graus

          if _DEBUG has been defined elsewhre, it defeines DEBUG_NEW and undefines THIS_FILE, then sets it to the current file namae. It's not C++, it's nasty C preprocessor stuff. Avoid if you can.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          Christian Graus wrote:

          it's nasty C preprocessor stuff. Avoid if you can

          :-D Maybe, but it's really handy for debugging MFC apps ;P

          "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

          1 Reply Last reply
          0
          • T tyagineha

            What does the following code do????????? #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif NT

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            For debug builds, it tells the compiler to use the crt debug "new" operator instead of the normal one. The debug version adds leak detection and maybe some other stuff. It also, as metioned, sets the THIS_FILE define to the current file. This information is used when dumping memory leak info. Mark

            "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

            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