Solved

what is the equivalent win32 function for MFC TRACE?

Posted on 2000-02-28
12
339 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

728 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