【note】stm32 keilMDK出现warning: function XX declared implicitly

本文介绍了如何解决在KEIL中编译STM32程序时遇到的函数隐式声明警告问题,并提供了具体步骤来修正此类错误。同时,还讨论了在不同编译环境下可能遇到的类似问题。

warning: #223-D: function "CLR_TX_DATA" declared implicitly

 

解决方法。

 

以上面错误提示为例:

 

 1  找到定义函数 CLR_TX_DATA() 的源文件 ,这里假设在 a.c  中;

 

  a.h 最后声明一下 CLR_TX_DATA(),即添加(假设此函数无返回值无参数)  

                     void  CLR_TX_DATAvoid);

 3  再次编译 刚才的 warning  即可消失。

 

 

参考自

KEIl编译STM32的时候,出现了一点问题!!

程序编译的时候通过了!!但是显示警告:

test.c(45): warning:  #223-D: function "Get_Temp"declaredimplicitly

在望山查了好久,终于明白:

这是因为Get_Temp没有在你所引用的文件里加载,虽然你在头文件里声明了一遍!!

但是还是有错误,

你只需要在你所使用的文件里面在声明一次,问题迎刃而解!!

 

另外

在VC中,好像不会有此warning ,它应该是intel编译器特有的警信息:

如果无法为非 void 返回类型的 C 函数找到正确的原型,则"英特尔® C++ 编译器"会打印以下警告消息:

warning #266: function declared implicitly

此问题只会在 C 语言函数中发生。在 C++ 函数中,必须声明正确的原型才能成功编译和链接,所以不会发生上述问题。

如以下C程序

 

main()

{

 printf("ok\n");

}

 

就会产生警告

正确的作法是写出函数的定义或#include函数定义的头文件,这样就没问题

 

 

 

 

 

Build started: Project: bbss *** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\k5\ARM\ARMCC\Bin' Build target 'bbss' Note: source file '../Core/Src/system_stm32f4xx.c' - object file renamed from 'bbss\system_stm32f4xx.o' to 'bbss\system_stm32f4xx_1.o'. compiling adc.c... compiling tim.c... compiling stm32f4xx_hal_msp.c... compiling i2c.c... compiling dac.c... compiling gpio.c... compiling system_stm32f4xx.c... compiling main.c... ..\Core\Src\main.c(24): warning: #223-D: function "SystemClock_Config" declared implicitly SystemClock_Config(); ..\Core\Src\main.c(33): warning: #223-D: function "OLED_Init" declared implicitly OLED_Init(); ..\Core\Src\main.c(34): warning: #223-D: function "OLED_Clear" declared implicitly OLED_Clear(); ..\Core\Src\main.c(80): warning: #223-D: function "OLED_ShowString" declared implicitly OLED_ShowString(0, 0, "Timeout "); ..\Core\Src\main.c(82): warning: #223-D: function "OLED_ShowString" declared implicitly OLED_ShowString(0, 0, "Hi "); ..\Core\Src\main.c(84): warning: #223-D: function "sprintf" declared implicitly sprintf(buffer, "%.1f kΩ", resistance); ..\Core\Src\main.c(85): warning: #223-D: function "OLED_ShowString" declared implicitly OLED_ShowString(0, 0, buffer); ..\Core\Src\main.c(106): warning: #223-D: function "fabs" declared implicitly if (fabs(current_resistance - prev_resistance) < 0.1f) { ..\Core\Src\main.c(122): warning: #223-D: function "OLED_ShowString" declared implicitly OLED_ShowString(0, 0, "Timeout "); ..\Core\Src\main.c(124): warning: #1-D: last line of file ends without a newline } ..\Core\Src\main.c(18): warning: #550-D: variable "stability_counter" was set but never used static uint32_t stability_counter = 0; ..\Core\Src\main.c: 11 warnings, 0 errors
03-23
根据错误提示修改代码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 display.c... ..\APP\display.h(36): warning: #1-D: last line of file ends without a newline #endif ..\APP\display.c: 1 warning, 0 errors compiling main.c... ..\USER\main.c(4): error: #20: identifier "TimeStruct" is undefined extern TimeStruct currentTime; ..\USER\main.c(15): warning: #223-D: function "systick_init" declared implicitly systick_init(); // 系统滴答定时器初始化 ..\USER\main.c(19): warning: #223-D: function "led_init" declared implicitly led_init(); // LED初始化(用于系统状态指示) ..\USER\main.c(20): warning: #223-D: function "display_init" declared implicitly display_init(); // 数码管显示初始化 ..\USER\main.c(21): warning: #223-D: function "keys_init" declared implicitly keys_init(); // 按键初始化(用于时间调整) ..\USER\main.c(26): warning: #223-D: function "tim4_init" declared implicitly tim4_init(200-1, 360-1); ..\USER\main.c(29): warning: #223-D: function "set_time" declared implicitly set_time(12, 0, 0); // 设置初始时间为12:00:00 ..\USER\main.c(38): warning: #223-D: function "PCout" declared implicitly PCout(13) = !PCin(13); ..\USER\main.c(38): warning: #223-D: function "PCin" declared implicitly PCout(13) = !PCin(13); ..\USER\main.c(38): error: #137: expression must be a modifiable lvalue PCout(13) = !PCin(13); ..\USER\main.c(39): warning: #223-D: function "delay_ms" declared implicitly delay_ms(500); ..\USER\main.c(42): warning: #223-D: function "handle_keypress" declared implicitly handle_keypress(&adjust_mode); ..\USER\main.c: 10 warnings, 2 errors assembling startup_stm32f10x_md.s... compiling system_stm32f10x.c... compiling stm32f10x_rcc.c... compiling core_cm3.c... compiling misc.c... compiling stm32f10x_gpio.c... compiling delay.c... compiling stm32f10x_it.c... compiling led.c... compiling timer.c... ..\APP\display.h(36): warning: #1-D: last line of file ends without a newline #endif ..\APP\timer.c(58): error: #136: struct "<unnamed>" has no field "blinkPhase" dsp.blinkPhase = !dsp.blinkPhase; // 翻转闪烁相位 ..\APP\timer.c(58): error: #136: struct "<unnamed>" has no field "blinkPhase" dsp.blinkPhase = !dsp.blinkPhase; // 翻转闪烁相位 ..\APP\timer.c(64): error: #20: identifier "COLON_SYMBOL" is undefined dsp.digit[2] = COLON_SYMBOL; // 冒号 ..\APP\timer.c(70): error: #136: struct "<unnamed>" has no field "colonMask" dsp.colonMask = (1 << 2); // 第3位显示冒号 (索引2) ..\APP\timer.c(71): error: #136: struct "<unnamed>" has no field "blinkMask" dsp.blinkMask = (1 << 2); // 第3位闪烁 ..\APP\timer.c: 1 warning, 5 errors compiling key.c... ..\APP\display.h(36): warning: #1-D: last line of file ends without a newline #endif ..\APP\key.c(7): warning: #223-D: function "key_scan" declared implicitly uint8_t current_key_state = key_scan(); ..\APP\key.c(21): error: #20: identifier "currentTime" is undefined uint8_t h = currentTime.hours; ..\APP\key.c(23): warning: #223-D: function "set_time" declared implicitly set_time(h, currentTime.minutes, currentTime.seconds); ..\APP\key.c(27): error: #20: identifier "currentTime" is undefined uint8_t m = currentTime.minutes; ..\APP\key.c(29): warning: #223-D: function "set_time" declared implicitly set_time(currentTime.hours, m, currentTime.seconds); ..\APP\key.c(36): error: #20: identifier "currentTime" is undefined uint8_t h = currentTime.hours; ..\APP\key.c(38): warning: #223-D: function "set_time" declared implicitly set_time(h, currentTime.minutes, currentTime.seconds); ..\APP\key.c(42): error: #20: identifier "currentTime" is undefined uint8_t m = currentTime.minutes; ..\APP\key.c(44): warning: #223-D: function "set_time" declared implicitly set_time(currentTime.hours, m, currentTime.seconds); ..\APP\key.c(48): warning: #1-D: last line of file ends without a newline } ..\APP\key.c: 7 warnings, 4 errors compiling stm32f10x_tim.c... ".\Objects\display.axf" - 11 Error(s), 19 Warning(s). Target not created. Build Time Elapsed: 00:00:02
06-07
Build started: Project: Project *** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil533\ARM\ARMCC\Bin' Build target 'Target 1' Note: source file 'E:\small car\STM32-10B智能小车资料\3.案例程序\ZY10A-STM32\5.机器人红外循迹传感器循迹\System\Delay.c' - object file renamed from '.\Objects\Delay.o' to '.\Objects\delay_1.o'. compiling OLED.c... delay.h(9): warning: #1-D: last line of file ends without a newline #endif OLED.h(31): warning: #1-D: last line of file ends without a newline /* 文件末尾换行 */ OLED.c(28): warning: #223-D: function "Delay_us" declared implicitly Delay_us(4); OLED.c(37): warning: #223-D: function "Delay_us" declared implicitly Delay_us(4); OLED.c(46): warning: #223-D: function "Delay_us" declared implicitly Delay_us(2); OLED.c(51): warning: #223-D: function "Delay_us" declared implicitly Delay_us(2); OLED.c(83): warning: #1-D: last line of file ends without a newline } OLED.c(14): warning: #177-D: function "OLED_I2C_Init" was declared but never referenced static void OLED_I2C_Init(void) { OLED.c(55): warning: #177-D: function "OLED_WriteCmd" was declared but never referenced static void OLED_WriteCmd(uint8_t cmd) { OLED.c: 9 warnings, 0 errors linking... .\Objects\Project.axf: Error: L6218E: Undefined symbol OLED_Init (referred from main.o). .\Objects\Project.axf: Error: L6218E: Undefined symbol OLED_Refresh (referred from main.o). .\Objects\Project.axf: Error: L6218E: Undefined symbol OLED_ShowNum (referred from main.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\Project.axf" - 3 Error(s), 9 Warning(s). Target not created. Build Time Elapsed: 00:00:00
03-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kobesdu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值