-
在 Keil MDK 中,编译项目时,出现如下警告信息
*** Using Compiler 'V5.06 update 1 (build 61)', folder: 'D:\Keil_v5\ARM\ARMCC\Bin'
Rebuild target 'Target 1'
assembling startup_stm32f103xe.s...
compiling stm32f1xx_hal.c...
compiling stm32f1xx_hal_dma.c...
compiling stm32f1xx_it.c...
compiling stm32f1xx_hal_cortex.c...
compiling stm32f1xx_hal_gpio.c...
compiling stm32f1xx_hal_uart.c...
compiling delay.c...
compiling sys.c...
compiling system_stm32f1xx.c...
compiling main.c...
....\User\main.c(17): warning: #177-D: variable "key" was declared but never referenced
uint8_t key;
....\User\main.c: 1 warning, 0 errors
compiling usart.c...
compiling stm32f1xx_hal_rcc_ex.c...
compiling stm32f1xx_hal_gpio_ex.c...
compiling stm32f1xx_hal_usart.c...
compiling stm32f1xx_hal_rcc.c...
compiling beep.c...
compiling led.c...
compiling exti.c...
compiling key.c...
linking...
Program Size: Code=5558 RO-data=362 RW-data=28 ZI-data=1900
FromELF: creating hex file...
"....\Output\hal_exti.axf" - 0 Error(s), 1 Warning(s).
Build Time Elapsed: 00:00:07关键错误
....\User\main.c(17): warning: #177-D: variable "key" was declared but never referenced
uint8_t key;
....\User\main.c: 1 warning, 0 errors
问题原因
- 这个警告信息表示,在
main.c
文件中定义了一个uint8_t key
变量,但后续代码中从未使用
处理策略
-
如果确实不需要,删除未使用的变量
-
如果逻辑需要,添加使用该变量的代码