#pragma message 官方文档翻译

一 作用

Sends a string literal to the standard output without terminating the compilation.

在不终止编译的情况下将字符串字面量发送到标准输出

二 语法

#pragma message( message-string )

三 备注

A typical use of the message pragma is to display informational messages at compile time.
The message-string parameter can be a macro that expands to a string literal, and you can concatenate such macros with string literals in any combination.
If you use a predefined macro in the message pragma, the macro should return a string. Otherwise, you'll have to convert the output of the macro to a string.
The following code fragment uses the message pragma to display messages during compilation:

翻译:message pragma的一个典型应用是在编译时显示信息消息。
message-string参数可以是一个宏扩展为一个字符串字面量,你可以以任何形式组合宏和字符串字面量。
如果在message pragma中预定义宏,该宏必须返回一个字符串,否则你必须将宏的输出转换为字符串。以下片段使用message pragma在编译过程中显示消息。

// pragma_directives_message1.cpp
// compile with: /LD
#if _M_IX86 >= 500
#pragma message("_M_IX86 >= 500")
#endif

#pragma message("")

#pragma message( "Compiling " __FILE__ )
#pragma message( "Last modified on " __TIMESTAMP__ )

#pragma message("")

// with line number
#define STRING2(x) #x
#define STRING(x) STRING2(x)

#pragma message (__FILE__ "[" STRING(__LINE__) "]: test")

#pragma message("")

四 原文

官方文档

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值