language lawyer - What's the utility of an empty C++ file? -
language lawyer - What's the utility of an empty C++ file? -
the sec part of translation phase 2 (section 2.2.2 in n3485) says if source file not end in newline character, compiler should treat if did.
however, if i'm reading correctly makes explicit exception empty source files, remain empty.
the exact text (with added emphasis) is:
each instance of backslash character (\
) followed new-line character deleted, splicing physical source lines form logical source lines. lastly backslash on physical source line shall eligible beingness part of such splice. if, result, character sequence matches syntax of universal-character-name produced, behavior undefined. a source file not empty , not end in new-line character, or ends in new-line character preceded backslash character before such splicing takes place, shall processed if additional new-line character appended file.
i haven't been able figure out situations in create difference whether source file empty or consisted of newline character.
i'm hoping can shed lite on reasoning behind requirement.
i think thought source file consists of 0 or more lines, , each line consists of sequence of non-new-line characters followed new-line. source file not meeting requirement needs special handling (so don't lines composed of text 2 different source files).
an empty c++ source file not particularly useful, there's no point in forbidding it. quoted clause isn't distinguishing between empty file , file consisting of 1 new-line (there should no real difference between them).
c++ language-lawyer
Comments
Post a Comment