【发布时间】:2012-06-09 18:34:42
【问题描述】:
可能重复:
Is there a portable way to print a message from the C preprocessor?
在大型代码库中导航时,有时很难猜测定义了什么,没有定义什么。因此,我想在编译时打印一些东西。例如:
#ifdef SOME_DEFINE
// I want a preprocessor to print something here so that
// I can know whether SOME_DEFINE is defined or not
#endif
这可能与 C 相关吗?
我在某处看到了一个叫#error 的东西。也许这是我唯一的选择,或者不是?
【问题讨论】:
-
已经有很多关于这个的问题了:stackoverflow.com/questions/3826832/…
-
如果预处理器支持,比
#error更好的是#warning。
标签: c c-preprocessor