这种错误是由于stm32函数库版本问题引起
#include 是旧版的 头文件
#include "stm32f10x.h" 是新版的头文件
把他们互换就好了。
compiling core_cm3.c...
compiling system_stm32f10x.c...
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(23): error: #256: invalid redeclaration of type name "s32" (declared at line 487 of "..\CMSIS\stm32f10x.h")
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef signed long s32;
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(27): error: #256: invalid redeclaration of type name "sc32" (declared at line 491 of "..\CMSIS\stm32f10x.h")
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef signed long const sc32; /* Read Only */
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(31): error: #256: invalid redeclaration of type name "vs32" (declared at line 495 of "..\CMSIS\stm32f10x.h")
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef volatile signed long vs32;
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(35): error: #256: invalid redeclaration of type name "vsc32" (declared at line 499 of "..\CMSIS\stm32f10x.h")
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef volatile signed long const vsc32; /* Read Only */
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(39): error: #256: invalid redeclaration of type name "u32" (declared at line 503 of "..\CMSIS\stm32f10x.h")
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef unsigned long u32;
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(43): error: #256: invalid redeclaration of type name "uc32" (declared at line 507 of "..\CMSIS\stm32f10x.h")
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef unsigned long const uc32; /* Read Only */
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(47): error: #256: invalid redeclaration of type name "vu32" (declared at line 511 of "..\CMSIS\stm32f10x.h")
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef volatile unsigned long vu32;
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(51): error: #256: invalid redeclaration of type name "vuc32" (declared at line 515 of "..\CMSIS\stm32f10x.h")
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef volatile unsigned long const vuc32; /* Read Only */
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(57): error: #101: "RESET" has already been declared in the current scope
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(57): error: #101: "SET" has already been declared in the current scope
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(57): error: #256: invalid redeclaration of type name "FlagStatus" (declared at line 519 of "..\CMSIS\stm32f10x.h")
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(57): error: #256: invalid redeclaration of type name "ITStatus" (declared at line 519 of "..\CMSIS\stm32f10x.h")
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(59): error: #101: "DISABLE" has already been declared in the current scope
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(59): error: #101: "ENABLE" has already been declared in the current scope
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(59): error: #256: invalid redeclaration of type name "FunctionalState" (declared at line 521 of "..\CMSIS\stm32f10x.h")
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(62): error: #101: "ERROR" has already been declared in the current scope
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(62): error: #101: "SUCCESS" has already been declared in the current scope
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h(62): error: #256: invalid redeclaration of type name "ErrorStatus" (declared at line 524 of "..\CMSIS\stm32f10x.h")
E:\Program Files\KeilARM\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
互换后:
.\main.c(2): #include "stm32f10x.h" //#include "stm32f10x_lib.h"
.\stm32f10x_it.h(23): #include "stm32f10x.h" //#include "stm32f10x_lib.h"
.\Functions\AppProc.c(10): #include "stm32f10x.h" //#include
.\Functions\buzzer.c(10): #include "stm32f10x.h" //#include
.\Functions\Delay.c(1): #include "stm32f10x.h" //#include "stm32f10x_lib.h"
.\Functions\Display.c(10): #include "stm32f10x.h" //#include
.\Functions\EEPRom.c(1): #include "stm32f10x.h" //#include
.\Functions\HostUsart.c(10): #include "stm32f10x.h" //#include "stm32f10x_lib.h"
.\Functions\IO4094.c(1): #include "stm32f10x.h" //#include
.\Functions\KeyProc.c(10): #include "stm32f10x.h" //#include
.\Functions\Keyscanf.c(1): #include "stm32f10x.h" //#include
.\Functions\Memory.c(1): #include "stm32f10x.h" //#include