开发者

C99, "Despite the name, a non-directive is a preprocessing 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 开发者_Python百科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?


See http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_250.htm It is to clarify that

#define nothing(x) // Nothing    /* Case 1 */
nothing (
#nonstandard
)

is UB.


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

# non-directive

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜