stm32的cmake的unknown type name ‘*****‘; did you mean ‘****‘解决方案

[  7%] Building C object CMakeFiles/mpu6050Test.elf.dir/Core/Src/MPU6050/I2C.c.obj
[  7%] Building C object CMakeFiles/mpu6050Test.elf.dir/Core/Src/MPU6050/inv_mpu.c.obj
[ 10%] Building C object CMakeFiles/mpu6050Test.elf.dir/Core/Src/MPU6050/inv_mpu_dmp_motion_driver.c.obj
In file included from E:\GitProject\stm32\mpu6050Test\Drivers\STM32F1xx_HAL_Driver\Inc/stm32f1xx_hal_rcc.h:1144,
                 from E:\GitProject\stm32\mpu6050Test\Core\Inc/stm32f1xx_hal_conf.h:237,
                 from E:\GitProject\stm32\mpu6050Test\Drivers\STM32F1xx_HAL_Driver\Inc/stm32f1xx_hal.h:30,
                 from E:\GitProject\stm32\mpu6050Test\Drivers\CMSIS\Device\ST\STM32F1xx\Include/stm32f1xx.h:200,
                 from E:\GitProject\stm32\mpu6050Test\Drivers\STM32F1xx_HAL_Driver\Inc/stm32f1xx_hal_def.h:30,
                 from E:\GitProject\stm32\mpu6050Test\Core\Inc/MPU6050/I2C.h:1,
                 from E:\GitProject\stm32\mpu6050Test\Core\Src\MPU6050\I2C.c:1:
E:\GitProject\stm32\mpu6050Test\Drivers\STM32F1xx_HAL_Driver\Inc/stm32f1xx_hal_rcc_ex.h:1859:1: error: unknown type name 'HAL_StatusTypeDef'; did you mean 'FLASH_TypeDef'?
 HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef  *PeriphClkInit);
 ^~~~~~~~~~~~~~~~~
 FLASH_TypeDef

而且有很多同类错误,在外网摸索后发现了问题来源

#include <stm32f1xx_hal_def.h>
#include <stm32f1xx_hal_conf.h>
#include "stm32f1xx_hal.h"//然而我包含上面两个

换而言之,被重复引用了。按照论坛说法

不必包括特定的HAL部分(在我的情况下为#include“ stm32f7xx_hal_gpio.h”),而仅需包括完整的HAL标头(#include“ stm32f7xx_hal.h”)。

所以把

#include <stm32f1xx_hal_def.h>
#include <stm32f1xx_hal_conf.h>

删去即可

同时这个错误不止发生在有

#include "stm32f1xx_hal.h" 

的情况中,还可能出现在

[  3%] Building C object CMakeFiles/mpu6050Test.elf.dir/Core/Src/MPU6050/mpu6050.c.obj
In file included from E:\GitProject\stm32\mpu6050Test\Core\Src\MPU6050\mpu6050.c:1:
E:\GitProject\stm32\mpu6050Test\Drivers\CMSIS\Include/core_armv8mbl.h:1252:39: error: unknown type name 'IRQn_Type'; did you mean 'IPSR_Type'?
 __STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn)
                                       ^~~~~~~~~
                                       IPSR_Type

这种错误的解决是删去

#include <core_armv8mbl.h>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值