what is the equivalent win32 function for MFC TRACE?

Hi,

In MFC, we can use TRACE as printf to output some varialbles or objects.  Then, what are the similar functions in SDK?  

Thanks,

tao_shaobin
LVL 1
tao_shaobinAsked:
Who is Participating?
 
JMuConnect With a Mentor Commented:
Me.
0
 
laeuchliCommented:
Yes, see the macros (_RPT# and family) in crtdbg.h.
0
 
bbousquetCommented:
I'm pretty sure you can also use OutputDebugString, although there are no 'printf-style' parameters to it.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
WynCommented:
OutputDebugString()
0
 
WynCommented:
Oops ,
Don't read the comment because the 1 minute in between.
0
 
JMuCommented:
Well, I had to change my propesed answer to a comment because I was slow (no answers when I started writing my answer). Too long answer or am I a slow writer?

--------------

Is there any? Don't know. Anyway here's my TRACE.

// in header

#ifdef _DEBUG
      void TRACE( LPCTSTR format, ... );
#else
      #define TRACE
#endif

#define __countof(array) (sizeof(array)/sizeof(array[0]))

// in source code
#ifdef _DEBUG
void TRACE( LPCTSTR format, ... )
{
      va_list args;
      va_start( args, format );

      int length;
      TCHAR buffer[ 512 ];

      length = _vsntprintf( buffer, __countof(buffer), format, args );

      // was there an error? was the expanded string too long?
      ASSERT( length >= 0 );

      if ( length > 0 )
      {
            //printf( buffer );
            OutputDebugString( buffer );
      }

      va_end( args );
}
#endif

JMu
0
 
bbousquetCommented:
Wyn, I think JMu's answer is way better than yours. I suggest you retract your answer. [I had written it as a comment because OutputDebugString does not do what the TRACEx macro series do]

JMu's answer is a complete one.
0
 
WynCommented:
o,okay...
Btw:
JMu,are you clear with AM.PM ?
Regards
W.Yinan
0
 
JMuCommented:
AM is Above Moon and PM is Post Millennium, right?
0
 
tao_shaobinAuthor Commented:
Thanks for your advices.  Whom should I give credit to?

0
 
bbousquetCommented:
Yep, JMu definitely deserves the points.
0
 
WynCommented:
->AM is Above Moon and PM is Post Millennium, right?
========================
Why are you so funny ?
very funny you are,hahaha...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.