在自己的文件里调用HAL库的文件时出现了大量报错比如30个报错之类的
"ws2812b\ws2812b.axf" - 30 Error(s), 3 Warning(s).
我的头文件是这样的
以下是报错
../Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h(96): error: #101: "DMA1_Channel4_IRQn" has already been declared in the current scope
DMA1_Channel4_IRQn = 14, /*!< DMA1 Channel 4 global Interrupt */
../Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h(97): error: #101: "DMA1_Channel5_IRQn" has already been declared in the current scope
DMA1_Channel5_IRQn = 15, /*!< DMA1 Channel 5 global Interrupt */
../Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h(98): error: #101: "DMA1_Channel6_IRQn" has already been declared in the current scope
DMA1_Channel6_IRQn = 16, /*!< DMA1 Channel 6 global Interrupt */
../Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h(99): error: #101: "DMA1_Channel7_IRQn" has already been declared in the current scope
DMA1_Channel7_IRQn = 17, /*!< DMA1 Channel 7 global Interrupt */
../Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h(100): error: #101: "ADC1_2_IRQn" has already been declared in the current scope
ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */
../Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h(101): error: #101: "USB_HP_CAN1_TX_IRQn" has already been declared in the current scope
USB_HP_CAN1_TX_IRQn = 19, /*!< USB Device High Priority or CAN1 TX Interrupts */
../Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h(102): error: #101: "USB_LP_CAN1_RX0_IRQn" has already been declared in the current scope
USB_LP_CAN1_RX0_IRQn = 20, /*!< USB Device Low Priority or CAN1 RX0 Interrupts */
../Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h(103): error: #101: "CAN1_RX1_IRQn" has already been declared in the current scope
CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */
..\User\WS2812B.c: 3 warnings, 30 errors
"ws2812b\ws2812b.axf" - 30 Error(s), 3 Warning(s).
Target not created.
Build Time Elapsed: 00:00:00
解决方法是 :
去掉重复包含的头文件:#include "stm32f10x.h" // Device header
因为 #include "tim.h" 里面已经有包含 #include "stm32f10x.h" 了