关于assert函数的调用警告:implicit declaration of function 'ASSERT' is invalid in C99

本文详细解析了一个常见的C99编译错误——隐式声明函数'assert'无效。作者分享了在移植程序过程中遇到的大写与小写不匹配问题,强调了细心的重要性。

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

编译错误解决:implicit declaration of function ‘ASSERT’ is invalid in C99@TOC

其实这个函数调用很简单,加入这个头文件就行了,但是我的调用一直出现一个警告,找了好多天也找不到原因
警告如标题所示
今天终于发现是因为我移植过来的程序是大写,这里头文件定义的是小写,就是那么简单的问题,但是真的很难发现,还是需要细心!
这是assert的头文件这里是小写,调用也必须要是小写

*** Using Compiler 'V6.7', folder: 'G:\DanPianJi\Keil\ARM\ARMCLANG\Bin' Rebuild target 'Target 1' Libary/stm32f10x_bkp.c(23): warning: In file included from... ./Libary/stm32f10x_bkp.h(32): warning: In file included from... ./start\stm32f10x.h(478): warning: In file included from... ./start/core_cm3.h(950): error: unknown register name 'basepri' in asm register uint32_t __regBasePri __ASM("basepri"); ^ ./start/core_cm3.h(963): error: unknown register name 'basepri' in asm register uint32_t __regBasePri __ASM("basepri"); ^ ./start/core_cm3.h(976): error: unknown register name 'primask' in asm register uint32_t __regPriMask __ASM("primask"); ^ ./start/core_cm3.h(989): error: unknown register name 'primask' in asm register uint32_t __regPriMask __ASM("primask"); ^ ./start/core_cm3.h(1002): error: unknown register name 'faultmask' in asm register uint32_t __regFaultMask __ASM("faultmask"); ^ ./start/core_cm3.h(1015): error: unknown register name 'faultmask' in asm register uint32_t __regFaultMask __ASM("faultmask"); ^ ./start/core_cm3.h(1028): error: unknown register name 'control' in asm register uint32_t __regControl __ASM("control"); ^ ./start/core_cm3.h(1041): error: unknown register name 'control' in asm register uint32_t __regControl __ASM("control"); ^ ./start/core_cm3.h(1724): warning: implicit declaration of function '__dsb' is invalid in C99 [-Wimplicit-function-declaration] __DSB(); /* Ensure completion of memory access */ ^ ./start/core_cm3.h(773): note: expanded from macro '__DSB' #define __DSB() __dsb(0) ^ ./start/core_cm3.h(1724): warning: this function declaration is not a prototype [-Wstrict-prototypes] ./start/core_cm3.h(773): note: expanded from macro '__DSB' #define __DSB() __dsb(0) ^ Libary/stm32f10x_bkp.c(137): warning: implicit declaration of function 'assert_param' is invalid in C99 [-Wimplicit-function-declaration] assert_param(IS_BKP_TAMPER_PIN_LEVEL(BKP_TamperPinLevel)); ^ Libary/stm32f10x_bkp.c(137): warning: this function declaration is not a prototype [-Wstrict-prototypes] 4 warnings and 8 errors generated. compiling stm32f10x_bkp.c... Libary/stm32f10x_adc.c(23): warning: In file included from... ./Libary/stm32f10x_adc.h(32): warning: In file included from... ./start\stm32f10x.h(478): warning: In file included from... ./start/core_cm3.h(950): error: unknown register name 'basepri' in asm register uint32_t __regBasePri __ASM("basepri"); ^ ./start/core_cm3.h(963): error: unknown register name 'basepri' in asm register uint32_t __regBasePri __ASM("basepri"); ^ ./start/core_cm3.h(976): error: unknown register name 'primask' in asm register uint32_t __regPriMask __ASM("primask"); ^ ./start/core_cm3.h(989): error: unknown register name 'primask' in asm register uint32_t __regPriMask __ASM("primask"); ^ ./start/core_cm3.h(1002): error: unknown register name 'faultmask' in asm register uint32_t __regFaultMask __ASM("faultmask"); ^ ./start/core_cm3.h(1015): error: unknown register name 'faultmask' in asm register uint32_t __regFaultMask __ASM("faultmask"); ^ ./start/core_cm3.h(1028): error: unknown register name 'control' in asm register uint32_t __regControl __ASM("control"); ^ ./start/core_cm3.h(1041): error: unknown register name 'control' in asm register uint32_t __regControl __ASM("control"); ^ ./start/core_cm3.h(1724): warning: implicit declaration of function '__dsb' is invalid in C99 [-Wimplicit-function-declaration] __DSB(); /* Ensure completion of memory access */ ^ ./start/core_cm3.h(773): note: expanded from macro '__DSB'
最新发布
06-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值