Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

The TRACE Macro

Visual Studio 6.0

This topic explains how to use the TRACE macro during development to print or display debugging messages from a program. TRACE prints a string argument to your debugger.

Note   With 32-bit MFC, the only way to get debug output is via the debugger.

The TRACE macro can handle a variable number of arguments, similar to the way printf operates. Following are examples of different ways to use TRACE macros:

int x = 1;
int y = 16;
float z = 32.0;
TRACE( "This is a TRACE statement\n" );

TRACE( "The value of x is %d\n", x );

TRACE( "x = %d and y = %d\n", x, y );

TRACE( "x = %d and y = %x and z = %f\n", x, y, z );

The TRACE macro is active only in the debug version of the class library. After a program has been debugged, you can build a release version to deactivate all TRACE calls in the program.

Tip   When debugging Unicode, the TRACE0, TRACE1, TRACE2, and TRACE3 macros are easier to use because the _T macro is not needed.

For important information on the TRACE macro, see in the Class Library Reference and .

Show:
© 2015 Microsoft