how call TRACE in c++?please explain
for example with this simple code
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 );
If you mean “How can I trace the execution path of my code?” Then you need to use a source-level symbolic debugger.
In Linux this generally means using GDB for which there a number of GUI front ends; using GDB on the command line is arcane and laborious, it can be used through Eclipse or KDevelop for example, or the stand-alone Insight debugger. In Windows, the debugger will be specific to the compiler, but VC++ has about the best debugger available (and for free in the Express Edition).
In response to davit’s edit
Define a TRACE macro thus:
Note that the lack of a comma between
"%s::%s(%d)"andformatis deliberate. It prints a formatted string with source location prepended. I work in real-time embedded systems so often I also include a timestamp in the output as well.