Possible Duplicate:
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
的东西某处。也许这是我唯一的选择,或者不是?
最佳答案
对于 MS Visual C++:
#define __PRINT(str) __pragma(message(str))
关于c - 使用 C 预处理器打印一些内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10902446/