C规范里的趣闻Warning: no newline at end of file

来源:互联网 发布:python培训要多少钱 编辑:程序博客网 时间:2024/05/17 00:50

写过软件的人,编译软件的时候,大都遇到过这个提示,Warning: no newline at end of file 。这个warning不会引起bin文件任何异常。既然这样,引入这个warning报警,有什么意义呢。网上有不少细心人士探讨过,试图找到根源,以此总结经验,提高编程水平。但追踪的结果,却发现了一个有趣的现象。居然是C规范里的要求。

"The C language standard says
A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character.

Since this is a "shall" clause, we must emit a diagnostic message for a violation of this rule.
This is in section 2.1.1.2 of the ANSI C 1989 standard. Section 5.1.1.2 of the ISO C 1999 standard (and probably also the ISO C 1990 standard)." 


参考:

http://blog.csdn.net/feiyuan1/article/details/6007495

0 0
原创粉丝点击