9.5.7 Line directives

本文介绍了C#编译器中的行指令,它可改变编译器输出警告和错误时报告的行号与源文件名,常用于从其他文本输入生成C#源代码的元编程工具。还说明了行指令的语法格式,以及无指令、非默认和默认行指令时编译器的处理方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

9.5.7 Line directives
Line directives may be used to alter the line numbers and source file names
that are reported by the compiler in
output such as warnings and errors.
[Note: Line directives are most commonly used in meta-programming tools
that generate C# source code from
some other text input. end note]
pp-line::
whitespaceopt # whitespaceopt line whitespace line-indicator pp-new-line
line-indicator::
decimal-digits whitespace file-name
decimal-digits
default
file-name::
" file-name-characters "
file-name-characters::
file-name-character
file-name-characters file-name-character
file-name-character::
Any character except " (U+0022), and new-line
When no #line directives are present, the compiler reports true line
numbers and source file names in its output.
When processing a #line directive that includes a line-indicator that is
not default, the compiler treats the line
after the directive as having the given line number (and file name, if
specified).
A #line default directive reverses the effect of all preceding #line
directives. The compiler reports true line
information for subsequent lines, precisely as if no #line directives had
been processed.
[Note: Note that a file-name differs from a regular string literal in that
escape characters are not processed; the
./. character simply designates an ordinary back-slash character within a
file-name. end note]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值