分类: C/C++
2008-05-07 15:51:28
GCC中如果文件最后不加上一行空行的话,就会吐个warning:no newline at end of file。
在《》一文中,有C99的相关信息:
A backslash immediately before a newline has long been used to continue string literals, as well as preprocessing command lines. In the interest of easing machine generation of C, and of transporting code to machines with restrictive physical line lengths, the C89 Committee generalized this mechanism to permit any token to be continued by interposing a backslash/newline sequence. |
为了一致性,代码的每一行后面都应该有一个“结束符”,也就是newline。避免当被include的文件展开后,前一个文件的最后一行与后一个文件的第一行直接被连接成一行从而造成错误。
不过像Visual Stdio之类的IDE没有报错,大概是它们自己主动插入了“结束符”吧。