正文

C# 语言规范--2.5.5 诊断指令2006-09-04 10:53:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/vc2006/18252.html

分享到:

诊断指令用于显式生成错误信息和警告消息,这些信息的报告方式与其他编译时错误和警告相同。

pp-diagnostic:(pp 诊断:)
whitespaceopt   #   whitespaceopt   error   pp-message(空白可选   #   空白可选   error   pp 消息)
whitespaceopt   #   whitespaceopt   warning   pp-message(空白可选   #   空白可选   warning   pp 消息)
pp-message:(pp 消息:)
new-line(新行)
whitespace   input-charactersopt   new-line(空白   输入字符可选   新行)

示例:

#warning Code review needed before check-in
#if Debug && Retail
   #error A build can't be both debug and retail
#endif
class Test {...}

总是产生一个警告(“Code review needed before check-in”),如果同时定义条件符号 DebugRetail,则产生一个编译时错误(“A build can't be both debug and retail”)。注意 pp-message(pp 消息)可以包含任意文本;具体说来,它可以包含格式不正确的标记,比如“can't”中的单引号就是这样。

 

阅读(1647) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册