Solved

what is the equivalent win32 function for MFC TRACE?

Posted on 2000-02-28
12
335 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

839 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