gpt4 book ai didi

c++ - 一个空的 C++ 文件有什么用?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:19:20 25 4
gpt4 key购买 nike

翻译阶段 2 的第二部分(N3485 中的第 2.2.2 节)基本上说如果源文件不以换行符结尾,编译器应该将其视为以换行符结尾。

但是,如果我没看错的话,它会为空的源文件明确异常(exception),这些文件仍然是空的。

准确的文本(加上重点)是:

Each instance of a backslash character (\) immediately followed by a new-line character is deleted, splicing physical source lines to form logical source lines. Only the last backslash on any physical source line shall be eligible for being part of such a splice. If, as a result, a character sequence that matches the syntax of a universal-character-name is produced, the behavior is undefined. A source file that is not empty and that does not end in a new-line character, or that ends in a new-line character immediately preceded by a backslash character before any such splicing takes place, shall be processed as if an additional new-line character were appended to the file.

我无法弄清楚源文件是空的还是仅包含换行符的任何情况都会有所不同。

我希望有人能阐明这一要求背后的原因。

最佳答案

这是为了特别支持 1994 年国际混淆 C 代码竞赛“最严重滥用规则”类别的获奖作品:The world's smallest self-replicating program. Guaranteed.

关于c++ - 一个空的 C++ 文件有什么用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14969771/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com