tagging release
[dasher.git] / trunk / Src / Common / Trace.h
blob000283ebc6230474c15d89e6132cca5b2ef3c15e
1 // Trace.h
2 //
3 // Copyright (c) 2005 David Ward
5 #ifndef __Common_Trace_h__
6 #define __Common_Trace_h__
8 // Trace is a mechanism for printf-like debugging that can be switched on/off
9 // at compile time
11 // To use Trace, define DASHER_TRACE in your build files, or uncomment the
12 // following line
13 // #define DASHER_TRACE
15 // Use the DASHER_TRACEOUTPUT macro to format a message to trace
16 // Syntax is identicaly to printf:
18 // int i=6;
19 // DASHER_TRACEOUTPUT("Hello World %d", i);
21 // The behaviour of DASHER_TRACEOUTPUT can be customized by changing
22 // DasherTraceOutputImpl in Trace.cpp
24 // Note that if DASHER_TRACE is not defined, trace code should be completely
25 // removed by the compiler
27 #include <stdarg.h>
28 #include <stdio.h>
30 void DasherTraceOutput(const char *pszFormat, ...);
31 void DasherTraceOutputImpl(const char *pszFormat, va_list vargs);
33 inline void DasherTraceOutput(const char *pszFormat, ...) {
34 va_list v;
35 va_start(v, pszFormat);
36 DasherTraceOutputImpl(pszFormat, v);
37 va_end(v);
40 // Define main Trace macro
42 #ifdef DASHER_TRACE
44 // Active
45 #define DASHER_TRACEOUTPUT \
46 DasherTraceOutput
47 #else
49 // Inactive - function should never get called
50 #define DASHER_TRACEOUTPUT 1 ? (void) 0 : DasherTraceOutput
52 #endif // DASHER_TRACE
54 #endif