Click here to Skip to main content
15,884,099 members
Articles / Desktop Programming / MFC
Article

Navigate your TRACE outputs

Rate me:
Please Sign up or sign in to vote.
3.33/5 (6 votes)
28 Jul 2001CPOL 94.3K   754   28   12
Extended TRACE macros with easy source navigation

Introduction

XTrace replaces the standard MFC TRACE macros. The macros implemented in XTrace.h add the file name and the line number of the trace point to any trace message (using the built-in __FILE__ and __LINE__ macros). A double click on the trace message in the debug window navigates to the according source line.

Usage

  • If you want to use standard MFC TRACEs and XTRACEs side-by-side:
    1. Add xtrace.cpp to your project.
    2. Include xtrace.h in stdafx.h.
    3. Use TRACEx for standard MFC TRACE's and XTRACEx for navigable TRACE's.

  • If you want to navigate all TRACE outputs:
    1. Add xtrace.cpp to your project.
    2. Include xtracestd.h in stdafx.h. This will replace all standard MFC TRACEx macros with XTRACEx macros.

Updates

2000-10-23

  1. Evaluation of vargs in ExtTrace::Trace fixed.
  2. Macros are expanded to a single statement (using brackets and ',' operator).
  3. Newline will be appended to trace message if necessary.
  4. Macros renamed from TRACE to XTRACE (to use simple MFC TRACE's and XTRACE's side-by-side).
  5. Additional header xtracestd.h (include this header, if you want to replace all MFC TRACE macros with the according XTRACE macros).

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralDoesn't work on MSVC++.NET Pin
Anonymous16-Jul-02 21:55
Anonymous16-Jul-02 21:55 
GeneralDoesn't work on VC5 Pin
Member 100623-Oct-00 22:15
Member 100623-Oct-00 22:15 
The FormatV() member of CString was not public in VC5, so this does not work.

This amendment should fix it: Replace the line
CString strMessage; // The full trace message
in xtrace.cpp with

#if _MFC_VER < 0x0421
class CString0420 : public CString
{
public:
void FormatV(LPCTSTR lpszFormat, va_list argList)
{
CString::FormatV(lpszFormat, argList);
}
};

CString0420 strMessage;
#else
CString strMessage; // The full trace message
#endif
GeneralRe: Doesn't work on VC5 Pin
10-Nov-01 6:26
suss10-Nov-01 6:26 
GeneralAre you trying to make this too complex... Pin
Paul Westcott23-Oct-00 12:24
Paul Westcott23-Oct-00 12:24 
GeneralRe: Are you trying to make this too complex... Pin
Member 474023-Oct-00 14:15
Member 474023-Oct-00 14:15 
GeneralRe: Are you trying to make this too complex... Pin
Paul Westcott24-Oct-00 6:42
Paul Westcott24-Oct-00 6:42 
GeneralNot allways work Pin
Yury Goltsman22-Oct-00 4:55
Yury Goltsman22-Oct-00 4:55 
GeneralUpdated Pin
Member 474023-Oct-00 11:57
Member 474023-Oct-00 11:57 
GeneralDoesn't work on VC6, SP4 Pin
Member 100618-Oct-00 23:35
Member 100618-Oct-00 23:35 
GeneralBugfix Pin
Member 474019-Oct-00 0:24
Member 474019-Oct-00 0:24 
GeneralUpdated Pin
Member 474023-Oct-00 11:59
Member 474023-Oct-00 11:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.