用stm32f10x.h文件时的问题error: #35: #error directive: “Please select first the target STM32F10x
在用uvison4.x(MDK4.x)建立一个开发STM32F103的工程:test.uvproj
在工程中加入源程序main.c文件,源代码内容如下:
#include "stm32f10x.h"int main(void)
{
return 0;}编译会出现错误,使得入门者难以继续深入学习STM32。
错误提示的全部信息如下:
C:\Keil_STM32\ARM\INC\ST\STM32F10x\stm32f10x.h(80):error: #35: #error directive: "Please selectfirst the target STM32F10x device used in your application (instm32f10x.h file)"解决办法如下: 右键点击工程名,选择第一个options for target ,下面选择C/C++,在define文本框中输入:
STM32F10X_MD,USE_STDPERIPH_DRIVER即可。MD根据你选择的机种更换为LD或HD
再编译,会出现更多错误,例如: error: #256: invalid redeclaration of type name "s32" (declared at line 470 of "C:\Keil_STM32\ARM\INC\ST\STM32F10x\stm32f10x.h") #256: invalid redeclaration of type name "sc32" (declared at line 474 of "C:\Keil_STM32\ARM\INC\ST\STM32F10x\stm32f10x.h")...... error: #101: "RESET" has already been declared in the current scopeerror: #101: "SET" has already been declared in the current scope......error: #256: invalid redeclaration of type name "ErrorStatus" (declared at line 507 of "C:\Keil_STM32\ARM\INC\ST\STM32F10x\stm32f10x.h")warning: #47-D: incompatible redefinition of macro "HSE_Value" (declared at line 511 of "C:\Keil_STM32\ARM\INC\ST\STM32F10x\stm32f10x.h") 解决办法:
打开stm32f10x_conf.h文件,将第21行的“#include "stm32f10x_type.h"”注释掉,再保存stm32f10x_conf.h文件,重新编译即可。
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。