是否有可移植的方式从C预处理器打印消息? [英] Is there a portable way to print a message from the C preprocessor?

查看:82
本文介绍了是否有可移植的方式从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?

推荐答案

警告指令可能是您获得的最接近的指令,但它并不完全独立于平台:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆