keil 4.22 MDK 建工程时出现的重定义错误

Posted xiaoleiacm

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了keil 4.22 MDK 建工程时出现的重定义错误相关的知识,希望对你有一定的参考价值。

在更新官方的STM32 官方库3.5版本的函数库后,建立工程时会出现诸多重定义错误,例如:

D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(23): error:  #256: invalid redeclaration of type name "s32" (declared at line 487 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(27): error:  #256: invalid redeclaration of type name "sc32" (declared at line 491 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(31): error:  #256: invalid redeclaration of type name "vs32" (declared at line 495 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(35): error:  #256: invalid redeclaration of type name "vsc32" (declared at line 499 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(39): error:  #256: invalid redeclaration of type name "u32" (declared at line 503 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(43): error:  #256: invalid redeclaration of type name "uc32" (declared at line 507 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(47): error:  #256: invalid redeclaration of type name "vu32" (declared at line 511 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(51): error:  #256: invalid redeclaration of type name "vuc32" (declared at line 515 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(57): error:  #101: "RESET" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(57): error:  #101: "SET" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(57): error:  #256: invalid redeclaration of type name "FlagStatus" (declared at line 519 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(57): error:  #256: invalid redeclaration of type name "ITStatus" (declared at line 519 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(59): error:  #101: "DISABLE" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(59): error:  #101: "ENABLE" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(59): error:  #256: invalid redeclaration of type name "FunctionalState" (declared at line 521 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(62): error:  #101: "ERROR" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(62): error:  #101: "SUCCESS" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(62): error:  #256: invalid redeclaration of type name "ErrorStatus" (declared at line 524 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_conf.h(147): warning:  #47-D: incompatible redefinition of macro "HSE_Value" (declared at line 528 of ".\\CM3\\stm32f10x.h")
user\\main.c(30): error:  #20: identifier "GPIO_InitTypeDef" is undefined
user\\main.c(53): warning:  #223-D: function "RCC_APB2PeriphClockCmd" declared implicitly
user\\main.c(53): error:  #20: identifier "RCC_APB2Periph_GPIOB" is undefined
user\\main.c(53): error:  #20: identifier "RCC_APB2Periph_GPIOD" is undefined
user\\main.c(55): error:  #20: identifier "GPIO_Pin_5" is undefined
user\\main.c(56): error:  #20: identifier "GPIO_Mode_Out_PP" is undefined
user\\main.c(57): error:  #20: identifier "GPIO_Speed_50MHz" is undefined
user\\main.c(58): warning:  #223-D: function "GPIO_Init" declared implicitly
user\\main.c(60): error:  #20: identifier "GPIO_Pin_6" is undefined
user\\main.c(60): error:  #20: identifier "GPIO_Pin_3" is undefined
user\\main.c(66): error:  #20: identifier "GPIO_Pin_13" is undefined
user\\main.c(70): warning:  #223-D: function "GPIO_ResetBits" declared implicitly
user\\main.c(88): warning:  #223-D: function "GPIO_SetBits" declared implicitly
user\\main.c(88): error:  #20: identifier "GPIO_Pin_5" is undefined
user\\main.c(88): warning:  #223-D: function "GPIO_ResetBits" declared implicitly
user\\main.c(88): error:  #20: identifier "GPIO_Pin_6" is undefined
user\\main.c(88): error:  #20: identifier "GPIO_Pin_3" is undefined
compiling stm32f10x_rcc.c...
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(23): error:  #256: invalid redeclaration of type name "s32" (declared at line 487 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(27): error:  #256: invalid redeclaration of type name "sc32" (declared at line 491 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(31): error:  #256: invalid redeclaration of type name "vs32" (declared at line 495 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(35): error:  #256: invalid redeclaration of type name "vsc32" (declared at line 499 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(39): error:  #256: invalid redeclaration of type name "u32" (declared at line 503 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(43): error:  #256: invalid redeclaration of type name "uc32" (declared at line 507 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(47): error:  #256: invalid redeclaration of type name "vu32" (declared at line 511 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(51): error:  #256: invalid redeclaration of type name "vuc32" (declared at line 515 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(57): error:  #101: "RESET" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(57): error:  #101: "SET" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(57): error:  #256: invalid redeclaration of type name "FlagStatus" (declared at line 519 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(57): error:  #256: invalid redeclaration of type name "ITStatus" (declared at line 519 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(59): error:  #101: "DISABLE" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(59): error:  #101: "ENABLE" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(59): error:  #256: invalid redeclaration of type name "FunctionalState" (declared at line 521 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(62): error:  #101: "ERROR" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(62): error:  #101: "SUCCESS" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(62): error:  #256: invalid redeclaration of type name "ErrorStatus" (declared at line 524 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_conf.h(147): warning:  #47-D: incompatible redefinition of macro "HSE_Value" (declared at line 528 of ".\\CM3\\stm32f10x.h")
compiling stm32f10x_gpio.c...
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(23): error:  #256: invalid redeclaration of type name "s32" (declared at line 487 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(27): error:  #256: invalid redeclaration of type name "sc32" (declared at line 491 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(31): error:  #256: invalid redeclaration of type name "vs32" (declared at line 495 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(35): error:  #256: invalid redeclaration of type name "vsc32" (declared at line 499 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(39): error:  #256: invalid redeclaration of type name "u32" (declared at line 503 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(43): error:  #256: invalid redeclaration of type name "uc32" (declared at line 507 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(47): error:  #256: invalid redeclaration of type name "vu32" (declared at line 511 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(51): error:  #256: invalid redeclaration of type name "vuc32" (declared at line 515 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(57): error:  #101: "RESET" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(57): error:  #101: "SET" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(57): error:  #256: invalid redeclaration of type name "FlagStatus" (declared at line 519 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(57): error:  #256: invalid redeclaration of type name "ITStatus" (declared at line 519 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(59): error:  #101: "DISABLE" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(59): error:  #101: "ENABLE" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(59): error:  #256: invalid redeclaration of type name "FunctionalState" (declared at line 521 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(62): error:  #101: "ERROR" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(62): error:  #101: "SUCCESS" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(62): error:  #256: invalid redeclaration of type name "ErrorStatus" (declared at line 524 of ".\\CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_conf.h(147): warning:  #47-D: incompatible redefinition of macro "HSE_Value" (declared at line 528 of ".\\CM3\\stm32f10x.h")
compiling system_stm32f10x.c...
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(23): error:  #256: invalid redeclaration of type name "s32" (declared at line 487 of "CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(27): error:  #256: invalid redeclaration of type name "sc32" (declared at line 491 of "CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(31): error:  #256: invalid redeclaration of type name "vs32" (declared at line 495 of "CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(35): error:  #256: invalid redeclaration of type name "vsc32" (declared at line 499 of "CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(39): error:  #256: invalid redeclaration of type name "u32" (declared at line 503 of "CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(43): error:  #256: invalid redeclaration of type name "uc32" (declared at line 507 of "CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(47): error:  #256: invalid redeclaration of type name "vu32" (declared at line 511 of "CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(51): error:  #256: invalid redeclaration of type name "vuc32" (declared at line 515 of "CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(57): error:  #101: "RESET" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(57): error:  #101: "SET" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(57): error:  #256: invalid redeclaration of type name "FlagStatus" (declared at line 519 of "CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(57): error:  #256: invalid redeclaration of type name "ITStatus" (declared at line 519 of "CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(59): error:  #101: "DISABLE" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(59): error:  #101: "ENABLE" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(59): error:  #256: invalid redeclaration of type name "FunctionalState" (declared at line 521 of "CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(62): error:  #101: "ERROR" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(62): error:  #101: "SUCCESS" has already been declared in the current scope
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_type.h(62): error:  #256: invalid redeclaration of type name "ErrorStatus" (declared at line 524 of "CM3\\stm32f10x.h")
D:\\Keil2\\ARM\\INC\\ST\\STM32F10x\\stm32f10x_conf.h(147): warning:  #47-D: incompatible redefinition of macro "HSE_Value" (declared at line 528 of "CM3\\stm32f10x.h")

解决办法:

在官方给的函数库头文件路径(C:\\Users\\admin\\Desktop\\ARM3\\FWlib\\inc   )下 加入stm32f10x_conf.h头文件  下载链接(http://download.csdn.net/detail/xiaoleiacm/7134683)  

重新编译即可。

其他原因参照 http://blog.csdn.net/iceiilin/article/details/6100494

以上是关于keil 4.22 MDK 建工程时出现的重定义错误的主要内容,如果未能解决你的问题,请参考以下文章

keilmdk怎么查看宏定义值

最近刚入门stm32 我按原子教你玩stm32 用keil mdk5 直接用它给的文件创建工程,一直出错

cmake:基于MDK(Keil)的Nationstech.N32G45x平台交叉编译工具链定义

Keil MDK C (error: #29: expected an expression) 错误的解决

Keil MDK仿真调试STM32的时候直接进入SystemInit函数

Keil(MDK-ARM)使用教程_在线调试