I've got a set of debug macros in tracing.hh. Whether it generates code and output is controlled by a macro flag in the real source code:
// File: foo.cc
#define TRACING 0
#include "tracing.hh"
// Away we go . . .
TRACEF("debug message");
The flag TRACING should have a value; I usually toggle between 0 and 1.
Within tracing.h,
#ifdef TRACING
will tell me that tracing was defined.
#if TRACING
controls the definition of functional macros like TRACEF()
But what if TRACING has no value? Then #if TRACING
produces an error:
In file included from foo.c:3:
tracing.hh:73:12: error: #if with no expression
How can I test if TRACING is defined but has no value?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…