【发布时间】:2011-05-05 09:06:38
【问题描述】:
我在 tracking.hh 中有一组调试宏。是否生成代码和输出由真实源代码中的宏标志控制:
// File: foo.cc
#define TRACING 0
#include "tracing.hh"
// Away we go . . .
TRACEF("debug message");
标志TRACING应该有一个值;我通常在 0 和 1 之间切换。
在tracing.h中,
-
#ifdef TRACING会告诉我跟踪已定义。 -
#if TRACING控制函数宏的定义,如TRACEF()
但是如果 TRACING 没有价值怎么办?然后#if TRACING 产生错误:
In file included from foo.c:3:
tracing.hh:73:12: error: #if with no expression
如何测试 TRACING 是否已定义但没有值?
【问题讨论】:
标签: preprocessor c-preprocessor