Solved

what is the equivalent win32 function for MFC TRACE?

Posted on 2000-02-28
12
334 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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 …

822 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