当前位置: 首页 > news >正文

嵌入式开发问题:warning: #177-D: variable “key“ was declared but never referenced

  • 在 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 referenceduint8_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 referenceduint8_t key;
..\..\User\main.c: 1 warning, 0 errors
问题原因
  • 这个警告信息表示,在 main.c 文件中定义了一个 uint8_t key 变量,但后续代码中从未使用
处理策略
  1. 如果确实不需要,删除未使用的变量

  2. 如果逻辑需要,添加使用该变量的代码

http://www.dtcms.com/a/304770.html

相关文章:

  • 2025年Solar应急响应公益月赛-7月笔记ing
  • Generative AI in Game Development
  • Class24AlexNet
  • STM32——HAL库
  • HBase、MongoDB 和 Redis 的区别详解
  • 图片查重从设计到实现(7) :使用 Milvus 实现高效图片查重功能
  • Redis内存使用耗尽情况分析
  • 达梦数据库DM用户管理-三权分立与四权分立,用户创建与维护,用户与模式的关系,用户相关权限
  • Spring Boot 简单接口角色授权检查实现
  • Rust 实战二 | 开发简易版命令行工具 grep
  • uv工具使用记录(Linux系统)
  • 【C++算法】75.优先级队列_数据流中的第 K 大元素
  • React 中获取当前路由信息
  • Android权限机制详解:保障用户隐私与应用安全
  • pytorch格式转华为昇腾的om格式
  • 移动语义和右值引用有什么关系?
  • Prometheus-1--什么是Prometheus?
  • Leetcode——475. 供暖器
  • Python - property
  • 学习笔记-中华心法问答系统的性能提升
  • pnpm 入门与实践指南
  • 字节序详解
  • webpack 原理及使用
  • 纸板制造胶工艺学习1
  • FlinkCDC实现多数据源数据集的增量更新实战
  • 磁悬浮转子同频振动:自适应陷波器设计与稳定性深度解析(附MATLAB代码)
  • 8.项目起步(2)
  • 本土化DevOps实践新篇章:Gitee引领企业高效协作新时代
  • 自学嵌入式 day37 HTML
  • Go 客户端玩转 ES|QL API 直连与 Mapping Helpers 实战详解