在用RT-THREAD studio 2.1.4生成内核为4.0.4的工程时,如果启用RTC设备,则在编译时,会报如下错误:
> 5:02:47 **** Incremental Build of configuration Debug for project T1 ****
make -j8 all
arm-none-eabi-gcc "../drivers/drv_rtc.c"
arm-none-eabi-gcc "../drivers/drv_wdt.c"
arm-none-eabi-gcc "../cubemx/Src/main.c"
arm-none-eabi-gcc "../cubemx/Src/stm32f4xx_hal_msp.c"
arm-none-eabi-gcc "../applications/main.c"
../drivers/drv_rtc.c:211:17: error: conflicting types for 'rt_hw_rtc_register'
static rt_err_t rt_hw_rtc_register(rt_device_t device, const char *name, rt_uint32_t flag)
^
In file included from E:\Project\RTT-TEST\T1\rt-thread\components\drivers\include/rtdevice.h:33:0,
from ../drivers/drv_rtc.c:13:
E:\Project\RTT-TEST\T1\rt-thread\components\drivers\include/drivers/rtc.h:42:10: note: previous declaration of 'rt_hw_rtc_register' was here
rt_err_t rt_hw_rtc_register(rt_rtc_dev_t *rtc,
^
make: *** [drivers/subdir.mk:69: drivers/drv_rtc.o] Error 1
make: *** Waiting for unfinished jobs....
"make -j8 all" terminated with exit code 2. Build might be incomplete.
15:02:51 Build Failed. 3 errors, 0 warnings. (took 3s.735ms)
查了源码,发现在rtc.h里声明的rt_hw_rtc_register()函数和drv_rtc.h里的重复了。但实际上rtc.c里的rt_hw_rtc_register并没有被调用过。注释掉此函数,编译通过。
rtc.c中的函数既然无用,为什么还要写呢4.0.4这个版本发布时,没有遇到这种情况吗?
@mysterywolf 这个好像是你 6 个月前修改的,为啥他下载的代码和仓库里的不一样了?
我是基于芯片生成的工程,没有用BSP包。
照您说的,去掉drv_rtc.c中的register函数,还需要修改rt_hw_rtc_init中的相应调用,这样ok了。