打印
[技术问答]

为什么代码最后一行要加个回车

[复制链接]
957|19
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
koala889|  楼主 | 2022-4-13 15:37 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
MDK5
文件的最后,一定要有回车么?

没有就报错(警告),有就没事

翻了C语言的书,也没提这个

各位有没有同样的问题

使用特权

评论回复
沙发
huquanz711| | 2022-4-14 08:45 | 只看该作者
没有说啊。

使用特权

评论回复
板凳
qiangtech| | 2022-4-14 09:19 | 只看该作者
是这样的,MDK会这样,有些编译器没有这个要求。

使用特权

评论回复
地板
jasontu| | 2022-4-14 09:32 | 只看该作者
No need to add a space. Just move to the end of the last line in the file. Then press enter and save.

The warning is there because some tools will only process text that ends with a new-line character, so if the last text isn't followed by a new-line, that text will be ignored.

Almost all tools really process file data to the last character instead of to the last new-line character, but the compiler warning is there just to make sure that you don't get hurt if you move your code between different tools.

使用特权

评论回复
5
koala889|  楼主 | 2022-4-14 09:38 | 只看该作者
qiangtech 发表于 2022-4-14 09:19
是这样的,MDK会这样,有些编译器没有这个要求。

那可以在那里设置一下么?
或者说,每次想着多加几个回车

使用特权

评论回复
6
koala889|  楼主 | 2022-4-14 09:39 | 只看该作者
jasontu 发表于 2022-4-14 09:32
No need to add a space. Just move to the end of the last line in the file. Then press enter and save ...

嗯,看半天,大概意思明白了

使用特权

评论回复
7
qiangtech| | 2022-4-14 09:42 | 只看该作者
koala889 发表于 2022-4-14 09:38
那可以在那里设置一下么?
或者说,每次想着多加几个回车

我就是敲完最后多加两个回车,或者提示后加两个回车。

使用特权

评论回复
8
资深技术| | 2022-4-15 14:44 | 只看该作者
原因不知,我就是加两个回车

使用特权

评论回复
9
foxsbig| | 2022-4-18 13:13 | 只看该作者
keil的问题,习惯就好,倒不费事

使用特权

评论回复
10
tpgf| | 2022-5-3 18:42 | 只看该作者
这个不一定啊

使用特权

评论回复
11
drer| | 2022-5-3 18:52 | 只看该作者
是不是软件自己加上去的啊

使用特权

评论回复
12
qcliu| | 2022-5-3 18:59 | 只看该作者
不一定 这个是个人习惯

使用特权

评论回复
13
coshi| | 2022-5-3 19:11 | 只看该作者
并不是必要的

使用特权

评论回复
14
kxsi| | 2022-5-3 19:27 | 只看该作者
不是 一定 是个人需求或者是习惯

使用特权

评论回复
15
wiba| | 2022-5-3 19:33 | 只看该作者
这个无所谓吧 加不加都行 加几个也都行

使用特权

评论回复
16
kiwis66| | 2022-5-6 11:44 | 只看该作者
mdk专有属性

使用特权

评论回复
17
alxd| | 2022-5-24 09:36 | 只看该作者
编译器的问题,跟C语言没啥关系

使用特权

评论回复
18
Charlotte夏| | 2022-5-24 09:44 | 只看该作者
我觉得C语言好像没这么复杂吧

使用特权

评论回复
19
Candic12e| | 2022-5-24 10:08 | 只看该作者
这个好像是编译器对格式的要求,最后一行要回车

使用特权

评论回复
20
Belle1257| | 2022-5-24 11:35 | 只看该作者
我也遇到过这种警告,报错不至于

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

85

主题

473

帖子

2

粉丝