项目场景:

STM8L151G4XX单片机IAR工程编译报错.


问题描述

编译报错:Fatal Error[Pe035]: #error directive: “Please select first the target STM8L device used in your application (in stm8l15x.h file)”
这里的描述大概意思就是没有选择单片机型号分类,我们需要根据提示去设置。
打开 stm8l15x.h,我们可以看到以下代码:

#if !defined (STM8L15X_MD) && !defined (STM8L15X_MDP) && !defined (STM8L15X_HD) && !defined (STM8L15X_LD) \
&& !defined (STM8L05X_LD_VL) && !defined (STM8L05X_MD_VL) && !defined (STM8L05X_HD_VL) && !defined (STM8AL31_L_MD)#error "Please select first the target STM8L device used in your application (in stm8l15x.h file)"
#endif

这一部分就是为什么会报错的原因:没有进行相关宏定义
怎么去解决,在这个文件也有描述,需要根据单片机型号选择不同的宏定义

/* Uncomment the line below according to the target STM8L15x device used in yourapplication*/
/* #define STM8L15X_LD */     /*!< STM8L15X_LD: STM8L15x Low density devices */
/* #define STM8L15X_MD */     /*!< STM8L15X_MD: STM8L15x Medium density devices */
/* #define STM8L15X_MDP */    /*!< STM8L15X_MDP: STM8L15x Medium density plus devices */
/* #define STM8L15X_HD */     /*!< STM8L15X_HD: STM8L15x/16x High density devices */
/* #define STM8L05X_LD_VL */  /*!< STM8L05X_LD_VL: STM8L051xx3 Low density value line devices */
/* #define STM8L05X_MD_VL */  /*!< STM8L05X_MD_VL: STM8L052xx6 Medium density value line devices */
/* #define STM8L05X_HD_VL */  /*!< STM8L05X_HD_VL: STM8L052xx8 High density value line devices */
/* #define STM8AL31_L_MD */   /*!< STM8AL31_L_MD: STM8AL3x Medium density devices *//*  Tip: To avoid modifying this file each time you need to switch between thesedevices, you can define the device in your toolchain compiler preprocessor.- Low density STM8L15x devices are STM8L151C3, STM8L151K3, STM8L151G3, STM8L151F3,STM8L151C2, STM8L151K2, STM8L151G2 and STM8L151F2 microcontrollers where the Flash memory density ranges between 4 and 8 Kbytes.- Medium density STM8L15x devices are STM8L151C4, STM8L151C6, STM8L152C4,STM8L152C6, STM8L151K4, STM8L151K6, STM8L152K4, STM8L152K6, STM8L151G4,STM8L151G6, STM8L152G4 and STM8L152G6 microcontrollers where the Flash memorydensity ranges between 16 and 32 Kbytes.- Medium density Plus devices are STM8L151R6, STM8L152R6 microcontrollers wherethe Flash memory density is fixed and equal to 32 Kbytes and a wider range ofperipheral than the medium density devices.- High density STM8L15x devices are STM8L151x8, STM8L152x8, STM8L162R8 and STM8L162M8microcontrollers where the Flash memory density is fixed and equal to 64 Kbytes with the same peripheral set than Medium Density Plus devices.- Value line low density STM8L05xx devices are STM8L051x3 microcontrollerswith 8-KB Flash- Value line medium density STM8L05xx devices are STM8L052x6 microcontrollers with 32-KB Flash- Value line high density STM8L05xx devices: STM8L052x8 microcontrollerswith 64-KB Flash- Medium density STM8AL31xx/STM8AL3Lxx devices: STM8AL3168, STM8AL3166, STM8AL3148,STM8AL3146, STM8AL3138, STM8AL3136, STM8AL3L68, STM8AL3L66, STM8AL3L48, STM8AL3L46 microcontrollers with 8-KB, 16-KB or 32-KB Flash*/

解决方案:

方法一:
直接在 stm8l15x.h文件修改,删掉需要的宏定义的注释符号,以STM8L151G4XX为例,根据上面描述,该型号属于 Medium density 。

/* Uncomment the line below according to the target STM8L15x device used in yourapplication*/
/* #define STM8L15X_LD */     /*!< STM8L15X_LD: STM8L15x Low density devices */#define STM8L15X_MD           /*!< STM8L15X_MD: STM8L15x Medium density devices */
/* #define STM8L15X_MDP */    /*!< STM8L15X_MDP: STM8L15x Medium density plus devices */
/* #define STM8L15X_HD */     /*!< STM8L15X_HD: STM8L15x/16x High density devices */
/* #define STM8L05X_LD_VL */  /*!< STM8L05X_LD_VL: STM8L051xx3 Low density value line devices */
/* #define STM8L05X_MD_VL */  /*!< STM8L05X_MD_VL: STM8L052xx6 Medium density value line devices */
/* #define STM8L05X_HD_VL */  /*!< STM8L05X_HD_VL: STM8L052xx8 High density value line devices */
/* #define STM8AL31_L_MD */   /*!< STM8AL31_L_MD: STM8AL3x Medium density devices */

方法二:
设置路径Options->C/C++ Compiler->Preprocessor-Defined symbols

STM8L151的IAR工程编译报错Fatal Error[Pe035]: #error directive: “Please select first the target STM8L...相关推荐

  1. IAR工程编译报错Warning[Pe223]: function “Get_Tempreture“ declared implicitly......

    IAR工程编译报错Warning[Pe223]: function "Get_Tempreture" declared implicitly E:\stm32编程文件\编程文件\4 ...

  2. 鸿蒙工程编译报错:check whether the ‘app‘ sub-tag ‘apiVersion‘ label is notEmpty

    问题 鸿蒙工程编译报错: Please check 'entry' module config.json, check whether the 'app' sub-tag 'apiVersion' l ...

  3. oracle 10035 err 942,案例:Oracle日志报错 Fatal NI connect error 12170 TNS-12535 TNS-00505

    天萃荷净 Oracle数据库alert日志文件报错Fatal NI connect error 12170,通过查看mos相关文章找到解决办法 今天在一台服务器的日志文件中,发现如下信息: Fatal ...

  4. gitlab报错 fatal: index-pack failed error: RPC failed; result=18, HTTP code = 200解决方案

    gitlab报错 "fatal: index-pack failed error: RPC failed; result=18, HTTP code = 200",如下图 这个问题 ...

  5. Opencv3.0-python: 编译报错color.cpp:7456: error: (-215) scn == 3

    Opencv3.0-python: 编译报错color.cpp:7456: error: (-215) scn == 3 参考文章: (1)Opencv3.0-python: 编译报错color.cp ...

  6. gitlab报错 fatal index-pack failed error RPC failed result

    分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章.分享知识,造福人民,实现我们中华民族伟大复兴! gitl ...

  7. Keil 5 编译报错FCARM - Output Name not specified, please check ‘Options for Target - Utilities‘

    在keil 5添加了一个新文件(*.c)之后编译报错FCARM - Output Name not specified, please check 'Options for Target - Util ...

  8. kylin系统gcc编译报错fatal error:stadio.h: 没有那个文件或目录解决办法

    在进行内存容量极限测试时,出现编译报错如下: $sudo gcc eat-memory.c -o eat-memory eat-memory.c:1:10: fatal error: stdio.h: ...

  9. linux下编译报错:gcc: Syntax error: Unterminated quoted string

    本来可以编译的代码,换一个编译环境就边不过了. 报错:gcc: Syntax error: Unterminated quoted string 原因:工具链基于 bash写的,在 dash 下运行脚 ...

最新文章

  1. OpenStack平台功能性测试工具Tempest安装
  2. android查看wifi是否双频,Android判断wifi是5G还是2.4G
  3. 使用Open Liberty的开发模式最大程度地缩短周转时间
  4. 关于学力、同等学力与学历、同等学历的区别
  5. Java 中的 String 有没有长度限制?
  6. 小程序突破五层限制的方法
  7. 资源放送丨《Oracle数据库之Object的Access方法和结合方法》PPT视频
  8. 操作系统————P1 概念、功能和目标
  9. js跨域 jsop 使用
  10. 服务追踪系统_一键托管,阿里云全链路追踪服务正式商用:成本仅自建1/5或更少...
  11. 打算年后跳槽的注意了... 这个岗位,人才缺口30万 薪资水涨船高
  12. CSDN博客代码片黑色背景及代码高亮设置
  13. 国产数据库激荡 40 年
  14. Zynq7000硬件开发之总体硬件架构设计
  15. YYText 库学习总结
  16. Algorithm Analysis: common functions, asymptotic notation
  17. ttl转rs232发送十六进制_电脑USB转TTL串口RS232串口模块
  18. 双堆1.数据流的中位数
  19. openjudge 1.6.2 陶陶摘苹果
  20. c++工厂机器安排(贪心)

热门文章

  1. 一个二维表查询的实现
  2. 经典力学(动力学)——动量守恒定律与能量守恒定律
  3. JAVA开发运维(Jenkins中踩的坑)
  4. 十二核能让联发科引爆核弹战吗?
  5. 海康威视java读取摄像头数据
  6. java基础之java类型
  7. windows已经阻止此软件因为无法验证发行者,然后就是IE的控件iNetOffice5.CAB不能安装?
  8. 数据库周刊36丨2020年8月数据库排行;云厂商腾讯云增速第一;OceanBase集群安装;Oracle RAC调整网卡MTU值;不改代码解决sql性能问题;Mysql索引研究;TiDB电子书……
  9. Windows系统中vscode+MSVC的C++配置
  10. 在别人写的代码上做修改我是这样保证正确性