Solved

what is the equivalent win32 function for MFC TRACE?

Posted on 2000-02-28
12
336 Views
Last Modified: 2013-12-03
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
0
Comment
Question by:tao_shaobin
  • 4
  • 3
  • 3
  • +2
12 Comments
 
LVL 5

Expert Comment

by:laeuchli
ID: 2565592
Yes, see the macros (_RPT# and family) in crtdbg.h.
0
 
LVL 2

Expert Comment

by:bbousquet
ID: 2565611
I'm pretty sure you can also use OutputDebugString, although there are no 'printf-style' parameters to it.
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2565618
OutputDebugString()
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 5

Expert Comment

by:Wyn
ID: 2565628
Oops ,
Don't read the comment because the 1 minute in between.
0
 
LVL 1

Expert Comment

by:JMu
ID: 2565657
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
 
LVL 2

Expert Comment

by:bbousquet
ID: 2567120
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
 
LVL 5

Expert Comment

by:Wyn
ID: 2577391
o,okay...
Btw:
JMu,are you clear with AM.PM ?
Regards
W.Yinan
0
 
LVL 1

Expert Comment

by:JMu
ID: 2577706
AM is Above Moon and PM is Post Millennium, right?
0
 
LVL 1

Author Comment

by:tao_shaobin
ID: 2587526
Thanks for your advices.  Whom should I give credit to?

0
 
LVL 1

Accepted Solution

by:
JMu earned 50 total points
ID: 2587627
Me.
0
 
LVL 2

Expert Comment

by:bbousquet
ID: 2588039
Yep, JMu definitely deserves the points.
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2595308
->AM is Above Moon and PM is Post Millennium, right?
========================
Why are you so funny ?
very funny you are,hahaha...
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question