C99,“尽管有这个名称,非指令是预处理指令。”
标题中引用的脚注是什么意思?这是附在 6.10.3p11 上的脚注
如果参数列表中存在预处理标记序列,否则这些预处理标记将充当预处理指令,147) 行为未定义。
我查了一下发现
预处理指令由一系列预处理标记组成,这些标记以 # 预处理标记开头......
并且我没有找到与该语法匹配的非终端 non-directive
。它可以(但不是必须)以 #
预处理标记开始。那么我们是不是还得说下面的话呢?
“尽管有这个名称,预处理指令实际上是一个非指令。”
另外,该脚注的目的是什么?
What does the quoted footnote in the title mean? It's a footnote attached to 6.10.3p11
If there are sequences of preprocessing tokens within the list of arguments that would otherwise act as preprocessing directives,147) the behavior is undefined.
I checked up and found
A preprocessing directive consists of a sequence of preprocessing tokens that begins with a # preprocessing token that ...
and I didn't find the non-terminal non-directive
matching that syntax. It can, but doesn't have to, start with a #
preprocessing token. So wouldn't we have to say the following?
"Despite the name, a preprocessing directive is a non-directive."
Also, what is the purpose of that footnote?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅http://www.open-std.org/ jtc1/sc22/wg14/www/docs/dr_250.htm 需要澄清的是,这
是UB。
See http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_250.htm It is to clarify that
is UB.
我的 C99 副本没有那个脚注(它是原始的 - 你有应用 TR 修正的脚注吗?)但我认为这个想法是,如果你有
一个宏参数列表,那仍然是未定义的行为。
最好将“非指令性”设置为“非指令性”。生产包括
#
,我认为,它会简化 6.10p3,4 并消除这种混乱。My copy of C99 doesn't have that footnote (it's the original - do you have one with TR corrections applied?) but I think the idea is that if you have
inside a macro argument list, that's still undefined behavior.
It would have been better to make the <non-directive> production include the
#
, I think, it would simplify 6.10p3,4 as well as removing this confusion.