如何解决KEIL报错 error in include chain (cmsis_armcc.h): expected identfieror

本文介绍了一个常见的编译器错误,即编译器无法打开被引用的头文件导致的语法检查失败问题。该错误通常是因为编译器无法找到所需的.h文件,导致无法进行后续的语法检查。文章提供了一种解决方案,即通过修改UVCC.ini文件并添加特定命令来忽略某些文件引发的错误。

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

经过一番寻找终于找到了这个令人心烦的解决方法,首先说明这个错误是编译器的错误,也就是它抽风不正常工作了。

原因

In the most common case, the syntax checker was not able to open an include file, which is referenced by the currently edited source module. In that case, further syntax checking is stopped, because the ‘not found’ include file most likely contains required definitions, which would result in numerous, irrelevant errors.
上面是官网的解释,也就是说语法检查没办法打开你的include的.h文件,他就没办法检查了,所以就出错了。也就是打不开包含链(include chain)。

解决方法

忽略提示的错误,打开UVCC.ini(这个文件在MDK5\UV4目录下),添加如下命令:

cmsis_armcc.h   = *

意思就是忽略cmsis_armcc.h文件带来的所有错误。

官网链接
http://www.keil.com/support/docs/3787.htm

../Middlewares/ST/ARM/DSP/Inc/arm_math.h(1132): warning: #47-D: incompatible redefinition of macro "__PKHBT" (declared at line 852 of "../Drivers/CMSIS/Include/cmsis_armcc.h") #define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0x0000FFFF) | \ ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(1134): warning: #47-D: incompatible redefinition of macro "__PKHTB" (declared at line 855 of "../Drivers/CMSIS/Include/cmsis_armcc.h") #define __PKHTB(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0xFFFF0000) | \ ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(1735): error: #79: expected a type specifier __STATIC_FORCEINLINE int32_t __SMMLA( ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(1735): error: #101: "int32_t" has already been declared in the current scope __STATIC_FORCEINLINE int32_t __SMMLA( ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(1735): error: #141-D: unnamed prototyped parameters not allowed when body is present __STATIC_FORCEINLINE int32_t __SMMLA( ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(1740): error: #20: identifier "sum" is undefined return (sum + (int32_t) (((int64_t) x * y) >> 32)); ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(1740): error: #20: identifier "x" is undefined return (sum + (int32_t) (((int64_t) x * y) >> 32)); ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(1740): error: #20: identifier "y" is undefined return (sum + (int32_t) (((int64_t) x * y) >> 32)); ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(2680): error: #757: function "int32_t" is not a type name int32_t shift, ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(2695): error: #757: function "int32_t" is not a type name int32_t shift, ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(2793): error: #757: function "int32_t" is not a type name int32_t resetStateFlag); ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(2811): error: #757: function "int32_t" is not a type name int32_t resetStateFlag); ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(2830): error: #757: function "int32_t" is not a type name int32_t resetStateFlag); ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(5532): error: #757: function "int32_t" is not a type name int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(5545): error: #757: function "int32_t" is not a type name int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(5558): error: #757: function "int32_t" is not a type name int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(5571): error: #757: function "int32_t" is not a type name int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(5606): error: #757: function "int32_t" is not a type name int32_t * pTapDelay, ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(5642): error: #757: function "int32_t" is not a type name int32_t * pTapDelay, ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(5680): error: #757: function "int32_t" is not a type name int32_t * pTapDelay, ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(5718): error: #757: function "int32_t" is not a type name int32_t * pTapDelay, ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(6491): warning: #174-D: expression has no effect int32_t i; /* Index variable */ ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(6491): error: #65: expected a ";" int32_t i; /* Index variable */ ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(6495): error: #20: identifier "i" is undefined i = (int32_t) ((x - S->x1) / xSpacing); ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(6548): warning: #174-D: expression has no effect int32_t index; /* Index to read nearest output values */ ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(6548): error: #65: expected a ";" int32_t index; /* Index to read nearest output values */ ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(6553): error: #20: identifier "index" is undefined index = ((x & (q31_t)0xFFF00000) >> 20); ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(6606): warning: #174-D: expression has no effect int32_t index; /* Index to read nearest output values */ ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(6606): error: #65: expected a ";" int32_t index; /* Index to read nearest output values */ ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(6611): error: #20: identifier "index" is undefined index = ((x & (int32_t)0xFFF00000) >> 20); ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(6611): error: #31: expression must have integral type index = ((x & (int32_t)0xFFF00000) >> 20); ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(6611): error: #18: expected a ")" index = ((x & (int32_t)0xFFF00000) >> 20); ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(6911): error: #757: function "int32_t" is not a type name int32_t * circBuffer, ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(6912): error: #757: function "int32_t" is not a type name int32_t L, ../Middlewares/ST/ARM/DSP/Inc/arm_math.h(6914): error: #757: function "int32_t" is not a type name int32_t bufferInc, ..\User\modules\master_process.c: 5 warnings, 30 errors
06-07
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值