警告:文件未以空白行结束

Sunny_yang06 2008-04-19 12:31:22
加精
常使用gcc编译,如果最后一行不是空行,会有这样的警告。不知达人可以告知一下,为什么gcc这样设置?这样设置对程序有什么好处,即意义何在?谢谢
...全文
1117 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Wenxy1 2011-06-01
  • 打赏
  • 举报
回复
from gcc@gcc.gnu.org mailing list

Re: no newline at end of file

* To: moz at compsoc dot man dot ac dot uk
* Subject: Re: no newline at end of file
* From: DJ Delorie <dj at redhat dot com>
* Date: Sun, 15 Jul 2001 00:56:27 -0400
* CC: gcc at gcc dot gnu dot org
* References: <20010715024419.A84310@compsoc.man.ac.uk>

> What is the rationale for this warning ? What can break or is it a
> standards thing ?

Imagine foo.h:

blah blah blah<no newline>

Now bar.c:

#include "foo.h"
#include "grill.h"

Now imagine a preprocessor that isn't smart enough to put
the newline in for you...

blah blah blah#include "grill.h"

It may not include grill.h.

这里的确说得很好,呵呵.
李迟 2011-06-01
  • 打赏
  • 举报
回复
参考:
http://bbs.chinaunix.net/viewthread.php?tid=930633
http://gcc.gnu.org/ml/gcc/2003-11/msg01568.html
李迟 2011-06-01
  • 打赏
  • 举报
回复
这是c99规定的,在文件最后加个回车就行了。
knowledge_Is_Life 2008-04-30
  • 打赏
  • 举报
回复
lz要干嘛?
richard_ma 2008-04-20
  • 打赏
  • 举报
回复
看看编译原理也许有点帮助,可能是做词法或者语法分析的时候留个空行比较方便
dataat 2008-04-19
  • 打赏
  • 举报
回复
出现这个情况的原因,很可能是因为你是在window系统平台下编写的程序,然后上传的linux平台编译。如果在linux平台下使用vi等编译器不至于出这个问题。
至于这样设置有什么好处。汗,我也不知道

23,125

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧