STM32嵌入式开发"warning: last line of file ends without a newline"解决方法

本文介绍了一种解决Keil中出现的“warning:lastlineoffileendswithoutanewline”警告的方法。通过调整文件末尾的换行符,可以消除这一常见的编译警告。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

   刚进行嵌入式编程,使用keil进行程序编写。按照课本上一步步的往下做,当整个程序写完之后进行编译时却出现了“warning: last line of file ends without a newline”,这样的警告。自己试着在函数结尾另起一新行了,为什么还是出现这样的警告。看着特别不爽,于是到百度里去找答案。

   解决方法:

   1.将光标移到提示告警的代码最后一行(有代码的那一行)

   2.然后按住del键,直到确定下面没有回车行

   3.最后回车一下或多下即可
Rebuild started: Project: display *** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\MCUSTM32\ARM\ARMCC\Bin' Rebuild target 'display' Note: source file '..\CORE\system_stm32f10x.c' - object file renamed from '.\Objects\system_stm32f10x.o' to '.\Objects\system_stm32f10x_1.o'. compiling main.c... ..\APP\display.h(26): warning: #1-D: last line of file ends without a newline #endif /* __DISPLAY_H */ ..\USER\main.h(23): warning: #1-D: last line of file ends without a newline #endif /* __MAIN_H */ ..\USER\main.h(23): warning: #1-D: last line of file ends without a newline #endif /* __MAIN_H */ ..\APP\timer.h(9): warning: #1-D: last line of file ends without a newline #endif /* __TIMER_H */ ..\USER\main.c: 4 warnings, 0 errors compiling stm32f10x_it.c... assembling startup_stm32f10x_md.s... compiling system_stm32f10x.c... compiling display.c... ..\APP\display.h(26): warning: #1-D: last line of file ends without a newline #endif /* __DISPLAY_H */ ..\APP\display.c: 1 warning, 0 errors compiling core_cm3.c... compiling stm32f10x_rcc.c... compiling misc.c... compiling stm32f10x_gpio.c... compiling delay.c... compiling systick.c... ..\APP\systick.c(10): warning: #177-D: variable "GPIO_InitStructure" was declared but never referenced GPIO_InitTypeDef GPIO_InitStructure; ..\APP\systick.c: 1 warning, 0 errors compiling key.c... ..\APP\display.h(26): warning: #1-D: last line of file ends without a newline #endif /* __DISPLAY_H */ ..\USER\main.h(23): warning: #1-D: last line of file ends without a newline #endif /* __MAIN_H */ ..\APP\timer.h(9): warning: #1-D: last line of file ends without a newline #endif /* __TIMER_H */ ..\APP\key.c(78): warning: #1-D: last line of file ends without a newline } ..\APP\key.c: 4 warnings, 0 errors compiling timer.c... ..\APP\display.h(26): warning: #1-D: last line of file ends without a newline #endif /* __DISPLAY_H */ ..\USER\main.h(23): warning: #1-D: last line of file ends without a newline #endif /* __MAIN_H */ ..\USER\main.h(23): warning: #1-D: last line of file ends without a newline #endif /* __MAIN_H */ ..\APP\timer.h(9): warning: #1-D: last line of file ends without a newline #endif /* __TIMER_H */ ..\APP\timer.c: 4 warnings, 0 errors compiling stm32f10x_tim.c... linking... .\Objects\display.axf: Error: L6200E: Symbol currentTime multiply defined (by timer.o and main.o). .\Objects\display.axf: Error: L6200E: Symbol delay_ms multiply defined (by systick.o and delay.o). .\Objects\display.axf: Error: L6200E: Symbol systick_init multiply defined (by systick.o and delay.o). Not enough information to list image symbols. Not enough information to list load addresses in the image map. Finished: 2 information, 0 warning and 3 error messages. ".\Objects\display.axf" - 3 Error(s), 14 Warning(s). Target not created. Build Time Elapsed: 00:00:02修改
06-07
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值