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. AfxTrace without MFC

AfxTrace without MFC

Scheduled Pinned Locked Moved C / C++ / MFC
c++agentic-aidebuggingquestion
6 Posts 3 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.
  • S Offline
    S Offline
    Steven Mitcham
    wrote on last edited by
    #1

    I am looking for a way to use the TRACE macros without adding MFC to my project. Does anyone have macro definitions to do this? But if you do wrong, be afraid, for [the one in authority] does not bear the sword for nothing. He is God's servant, an agent of Wrath to bring punishment to the wrongdoer -- Romans 13:4

    C M 2 Replies Last reply
    0
    • S Steven Mitcham

      I am looking for a way to use the TRACE macros without adding MFC to my project. Does anyone have macro definitions to do this? But if you do wrong, be afraid, for [the one in authority] does not bear the sword for nothing. He is God's servant, an agent of Wrath to bring punishment to the wrongdoer -- Romans 13:4

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      void RDTrace(const char* fmt, ...)
      {
      #ifdef _DEBUG
      char buffer[1024];
      va_list argptr;
      va_start(argptr, fmt);
      _vsnprintf(buffer, 1024, fmt, argptr);
      va_end(argptr);

      OutputDebugString(buffer);
      

      #endif
      }

      ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com

      S 1 Reply Last reply
      0
      • C Chris Losinger

        void RDTrace(const char* fmt, ...)
        {
        #ifdef _DEBUG
        char buffer[1024];
        va_list argptr;
        va_start(argptr, fmt);
        _vsnprintf(buffer, 1024, fmt, argptr);
        va_end(argptr);

        OutputDebugString(buffer);
        

        #endif
        }

        ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com

        S Offline
        S Offline
        Steven Mitcham
        wrote on last edited by
        #3

        Thanks Chris, I just about got this far, but where is the OutputDebugString function declared? I'm currently using to dump my TRACE output to a file, but I would prefer it to come into the IDE so I can see it while it runs. But if you do wrong, be afraid, for [the one in authority] does not bear the sword for nothing. He is God's servant, an agent of Wrath to bring punishment to the wrongdoer -- Romans 13:4

        C 1 Reply Last reply
        0
        • S Steven Mitcham

          Thanks Chris, I just about got this far, but where is the OutputDebugString function declared? I'm currently using to dump my TRACE output to a file, but I would prefer it to come into the IDE so I can see it while it runs. But if you do wrong, be afraid, for [the one in authority] does not bear the sword for nothing. He is God's servant, an agent of Wrath to bring punishment to the wrongdoer -- Romans 13:4

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          OutputDebugString is a Win32 API function. #include Windows.h to get it. (it's actually in winbase.h). it's what TRACE ends up calling. ODS will even dump stuff in release mode, hence the #ifdef _DEBUG. you can even use the lovely WinDBG32 app to capture these message outside of the IDE. -c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com

          S 1 Reply Last reply
          0
          • C Chris Losinger

            OutputDebugString is a Win32 API function. #include Windows.h to get it. (it's actually in winbase.h). it's what TRACE ends up calling. ODS will even dump stuff in release mode, hence the #ifdef _DEBUG. you can even use the lovely WinDBG32 app to capture these message outside of the IDE. -c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com

            S Offline
            S Offline
            Steven Mitcham
            wrote on last edited by
            #5

            Thanks, I gave it a try and it worked. This is the first time I've actually had a question. It's great the speed with which this community answers questions. But if you do wrong, be afraid, for [the one in authority] does not bear the sword for nothing. He is God's servant, an agent of Wrath to bring punishment to the wrongdoer -- Romans 13:4

            1 Reply Last reply
            0
            • S Steven Mitcham

              I am looking for a way to use the TRACE macros without adding MFC to my project. Does anyone have macro definitions to do this? But if you do wrong, be afraid, for [the one in authority] does not bear the sword for nothing. He is God's servant, an agent of Wrath to bring punishment to the wrongdoer -- Romans 13:4

              M Offline
              M Offline
              Michael Dunn
              wrote on last edited by
              #6

              You can just grab the code for AfxTrace() from the MFC\src directory and copy it to your program, too. There's also ATLTRACE if you are using ATL. --Mike-- http://home.inreach.com/mdunn/ "Listen you footwarriors, can you hold down a bit with the firing? I've just got three impromptu weddings breaking out behind me!" -- Arthur Dent :love: your :bob: with :vegemite: and :beer:

              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