找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 22580|回復(fù): 1
收起左側(cè)

error: #35: #error directive: "Please select first the target STM32F10x

[復(fù)制鏈接]
ID:85109 發(fā)表于 2015-7-8 22:33 | 顯示全部樓層 |閱讀模式
用stm32f10x.h文件時(shí)的問(wèn)題
    在用uvison4.x(MDK4.x)建立一個(gè)開(kāi)發(fā)STM32F103的工程:test.uvproj
在工程中加入源程序main.c文件,源代碼內(nèi)容如下:
#include "stm32f10x.h"
int main(void)
{
  return 0;

}
編譯會(huì)出現(xiàn)錯(cuò)誤,使得入門(mén)者難以繼續(xù)深入學(xué)習(xí)STM32。
錯(cuò)誤提示的全部信息如下:
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)"
解決辦法如下:
   右鍵點(diǎn)擊工程名,選擇第一個(gè)options for target ,下面選擇C/C++,在define文本框中輸入:
STM32F10X_MD,USE_STDPERIPH_DRIVER即可。MD根據(jù)你選擇的機(jī)種更換為L(zhǎng)D或HD


   再編譯,會(huì)出現(xiàn)更多錯(cuò)誤,例如: 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")   解決辦法:打開(kāi)stm32f10x_conf.h文件,將第21行的“#include "stm32f10x_type.h"”注釋掉,再保存stm32f10x_conf.h文件,重新編譯即可。


評(píng)分

參與人數(shù) 1黑幣 +15 收起 理由
王朗的誘惑 + 15 很給力!

查看全部評(píng)分

回復(fù)

使用道具 舉報(bào)

ID:134810 發(fā)表于 2017-9-16 11:42 | 顯示全部樓層
謝謝分享
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表