c - "warning : No new line at end of file"是什么意思?

标签 c windows linux gcc cygwin

<分区>

Possible Duplicate:
“No newline at end of file” compiler warning

我是一个 Linux 用户,在工作中使用 gcc 但在家里我已经安装了 cygwin 包并在我的 Windows 机器上使用它的 gcc

每当我制作任何 .c 文件并在警告后运行其显示时

Warning : No new line at end of file 

当我在该 c 文件的末尾添加额外的新行时,警告消失了。 我在 Linux 中使用 gcc 时没有遇到过这样的警告。

所以

为什么我会收到此警告?这是什么意思?

编辑

这样做有什么必要或有什么好处?

如果它是 c 编程标准的一部分,那么为什么它在 linux 中工作时不会出现任何错误?

最佳答案

C 语言要求每个源文件必须以换行符结尾(来自 C99 5.1.1.2/1):

A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character before any such splicing takes place.

(C++在C++11之前也有这个要求)

关于c - "warning : No new line at end of file"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8172246/

相关文章:

c - 如何更改 intel cpu 中的智能缓存功能?

javascript - 创建 react 应用程序 : How do I "npm start" with a specific browser?

c - 如何: Safeguard memory - strncat()?

c++ - 尝试连接到 tcp 套接字时连接被拒绝 (linux)

c - 用C写十六进制(字节)

python - 在 Python 中实现函数的前向声明

c++ - sclite (SCTK),C++ 模板参数 Filter::Filter* 无效。 Cygwin

windows - 启动从批处理文件中隐藏的 exe

LInux shell : conditional conversion of character encoding, 多个文本文件

linux - 创建一个像普通菜单一样弹出但出现在鼠标位置的 float 菜单