OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Extended Diagnostics Macros Example

The following PROG.C example defines two diagnostic groups, Group1 and Group2, which are used as arguments to extended diagnostic macros:

#include <checks.h>
void main( int argc, char **argv )
{
TRACE( "Always works, argc=" << argc );
TRACEX( Group1, 0, "Hello" );
TRACEX( Group2, 0, "Hello" );
TRACEX( Group1, 0, "Won't execute - group is disabled!" );
TRACEX( Group2, 3, "Won't execute - level is too high!" );
}
Diagnostic macros for assertions and tracing.
#define DIAG_DEFINE_GROUP(group, enable, level)
Definition checks.h:408
#define TRACE(message)
Definition checks.h:255
#define TRACEX(group, level, message)
Definition checks.h:263

When the above code is compiled with _ _TRACE defined and run, it produces the following output:

Trace PROG.C 8: [Def] Always works, argc=1
Trace PROG.C 10: [Group1] Hello
Trace PROG.C 11: [Group2] Hello

Note that the last two macros are not executed. In the first case, the group Group1 is disabled. In the second case, the macro level exceeds Group2's threshold level (set by default to 0).