翻译阶段2的第二部分(
N3485中的第2.2.2节)基本上表示如果源文件不以换行符结尾,编译器应该将其视为原样.
但是,如果我正确读取它,它会为空源文件做一个显式异常,它们仍为空.
确切的文字(更加强调)是:
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.
我无法弄清楚源文件是空的还是仅由换行符组成的任何情况都会产生影响.
我希望有人可以说明这一要求背后的原因.
我认为这个想法是源文件通常由零行或多行组成,每行由一系列非换行符后跟一行换行组成.任何不满足该要求的源文件都需要特殊处理(因此您不会从两个不同的源文件中获取由文本组成的行).
空的C源文件不是特别有用,但禁止它是没有意义的.引用的子句不是要区分空文件和仅由一个新行组成的文件(它们之间应该没有真正的区别).