有没有一种可移植的方式来打印来自 C 预处理器的消息? [英] Is there a portable way to print a message from the C preprocessor?
本文介绍了有没有一种可移植的方式来打印来自 C 预处理器的消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够做类似的事情
I would like to be able to do something like
#print "C Preprocessor got here!"
用于调试目的.执行此操作的最佳/最便携方式是什么?
for debugging purposes. What's the best / most portable way to do this?
推荐答案
warning
指令可能是最接近的指令,但它并不完全独立于平台:
The warning
directive is probably the closest you'll get, but it's not entirely platform-independent:
#warning "C Preprocessor got here!"
AFAIK 这适用于大多数编译器,除了 MSVC,你必须使用 pragma
指令:
AFAIK this works on most compilers except MSVC, on which you'll have to use a pragma
directive:
#pragma message ( "C Preprocessor got here!" )
这篇关于有没有一种可移植的方式来打印来自 C 预处理器的消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文