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 predefinitions

some predefinitions

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++debugging
3 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.
  • F Offline
    F Offline
    FlyingDancer
    wrote on last edited by
    #1

    #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif As to the above, I don't know what effections they can have on the other places Can you tell me their important position in the MFC AppiWizard process, or what is in the charge of them? And how do they do that? Thanks for your attention!

    R 1 Reply Last reply
    0
    • F FlyingDancer

      #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif As to the above, I don't know what effections they can have on the other places Can you tell me their important position in the MFC AppiWizard process, or what is in the charge of them? And how do they do that? Thanks for your attention!

      R Offline
      R Offline
      Ryan Binns
      wrote on last edited by
      #2

      if you're performing a DEBUG build, then it redefines the new keyword to use the DEBUG_NEW macro. Basically, this adds in extra error checking when allocating and freeing memory, and enables the memory leak display that gets displayed by VS when you finish debugging a program. The THIS_FILE[] character array stores the current name of the file. This allows you to know the name of the current file in a form that can be manipulated. The __FILE__ macro contains the name of the file, but it is constant and can't be used everywhere that a non-constant array can. Hope this helps,

      Ryan

      "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

      F 1 Reply Last reply
      0
      • R Ryan Binns

        if you're performing a DEBUG build, then it redefines the new keyword to use the DEBUG_NEW macro. Basically, this adds in extra error checking when allocating and freeing memory, and enables the memory leak display that gets displayed by VS when you finish debugging a program. The THIS_FILE[] character array stores the current name of the file. This allows you to know the name of the current file in a form that can be manipulated. The __FILE__ macro contains the name of the file, but it is constant and can't be used everywhere that a non-constant array can. Hope this helps,

        Ryan

        "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

        F Offline
        F Offline
        FlyingDancer
        wrote on last edited by
        #3

        All those codes are valid when performing a debug build, do you think so? Does they work like: 1.Define "new" by "DEBUG_NEW" when detecting the building mode is debug Is that to say, "new" will always be replaced with "DEBUG_NEW", I think, DEBUG_NEW maybe contains some extra error checking codes, isn't it? 2.#undef THIS_FILE. Is it to avoid conflicting with the later same name or THIS_FILE is something to be used in a release build and it can't be used in a debug build? 3.why use "THIS_FILE[]" to substitute "THIS_FILE", can we use "THIS_FILE" directly? In the meantime, I have not see THIS_FILE[] used in another place

        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