VSCode使用EIDE编译keil程序报错
利用VSCode中的EIDE编译由keil导入的工程时报错
VSCode使用EIDE编译keil程序报错
利用VSCode中的EIDE编译由keil导入的工程时报错,报错信息如下:
>> [ 3%] CC '../FWLIB/src/stm32f10x_cec.c'
"../CMSIS/stm32f10x.h", line 95: Error: #35: #error directive: "Please select first the target STM32F10x device used in your application (in stm32f10x.h file)"
#error "Please select first the target STM32F10x device used in your application (in stm32f10x.h file)"
^
.\..\FWLIB\src\stm32f10x_dac.c: 0 warnings, 1 error
>> [ 39%] CC '../FWLIB/src/stm32f10x_exti.c'
"../CMSIS/stm32f10x.h", line 95: Error: #35: #error directive: "Please select first the target STM32F10x device used in your application (in stm32f10x.h file)"
#error "Please select first the target STM32F10x device used in your application (in stm32f10x.h file)"
^
.\..\FWLIB\src\stm32f10x_exti.c: 0 warnings, 1 error
>> [ 42%] CC '../CMSIS/core_cm3.c'
ERROR compilation failed at : "c:\MyFiles\STM32_Project\MHG4500-CT-0020\FWLIB\src\stm32f10x_exti.c", exit code: 1
command:
"c:\MyProgramFiles\Keil_v5\ARM\ARM_Compiler_5.06u7\bin\armcc.exe" -c --apcs=interwork -I../CMSIS -I../CMSIS/startup/arm -I../FWLIB/inc -I../USER -I.cmsis/include -IRTE/_MHG4500-CT-0020 -DUSE_STDPERIPH_DRIVER --cpu Cortex-M3 --li --c99 -O0 --split_sections --gnu --diag_suppress=1 --diag_suppress=1295 -g -o .\build\MHG4500-CT-0020\.obj\__\FWLIB\src\stm32f10x_exti.o --no_depend_system_headers --depend .\build\MHG4500-CT-0020\.obj\__\FWLIB\src\stm32f10x_exti.d .\..\FWLIB\src\stm32f10x_exti.c
ERROR build failed !, elapsed time 0:0:0
原因分析:
这是因为stm32f10x.h中没有对应的宏定义。
解决方案:
这里有两种方法可以解决该问题。
1.在VSCode的EIDE中添加预处理宏定义
1。在VSCode的EIDE中打开项目,
2.点击项目,
3.点击项目属性,
4.点击预处理宏定义的 + 符号,如下图
5.输入“STM32F10X_MD”,按enter确认添加,
6.添加完成后,预处理宏定义处如图所示
7.点击编译,编译成功
2.在keil中建立工程时进行配置
1.点击魔术棒进入配置
2.选择 C/C++
3.在Define中填入“STM32F10X_MD,USE_STDPERIPH_DRIVER”,其中STM32F10X_MD由自己的芯片而定
4.点击OK,如图所示
总结
以上就是该项报错的解决方法,大家可以按照自己的需求进行选择。