当前位置:首页 > 技术心得 > 正文内容

IAR STM8 #pragma optimize 指令

xjtudll9年前 (2017-06-18)技术心得29280

参考资料:http://blog.csdn.net/niepangu/article/details/38066319

#pragma optimize= none  //one of none, low, medium, high, size, or speed放在被优化函数前 
#pragma optimize 指令
格式:
#pragma optimize=token token token

我在IAR STM8里尝试,发现只能使用none, low, medium, high, size,  speed,且区分大小写。

不能用 s 9之类的,会报警:

f158bb59-a95a-490a-afd9-25fadd7b8c88

Warning[Go013]: Deprecated optimization level "9" encountered in #pragma optimize, please use one of none, low, medium, high, size, or speed

sshot-1_2

后面是参考文献介绍的,我尝试貌似不对,也有可能理解错误。

where token is one or more of the following:
s Optimizes for speed
z Optimizes for size
2|3|6|9 Specifies level of optimization
no_cse Turns off common sub-expression elimination
no_inline Turns off function inlining
no_unroll Turns off loop unrolling
no_code_motion Turns off code motion.
The #pragma optimize directive is used for decreasing the optimization level or for
turning off some specific optimizations. This #pragma directive only affects the
function that follows immediately after the directive.
Notice that it is not possible to optimize for speed and size at the same time. Only one
of the s and z tokens can be used.
Note: If you use the #pragma optimize directive to specify an optimization level that
is higher than the optimization level you specify using a compiler option, the #pragma
directive is ignored.
Example
#pragma optimize=s 9
int small_and_used_often()
{
...
}
#pragma optimize=z 9
int big_and_seldom_used()
{
...
}
/*======================================================================================
速度优化选项:
-s[2|3|6|9]
Use this option to make the compiler optimize the code for maximum execution speed.
If no optimization option is specified, the compiler will use the size optimization -z2
by default. If the -s option is used without specifying the optimization level, speed
optimization at level 2 is used by default.
*The most important difference between -s2 and -s3 is that at level 2, all non-static
variables will live during their entire scope.
大小优化选项
-z[2|3|6|9]
Use this option to make the compiler optimize the code for minimum size. If no
optimization option is specified, -z2 is used by default
*The most important difference between -z2 and -z3 is that at level 2, all non-static
variables will live during their entire scope.
2 None*
3 Low
6 Medium
9 High
========================================================================================*/

扫描二维码推送至手机访问。

版权声明:本文由鸟的天空发布,如需转载请注明出处。

本文链接:http://www.xjtudll.cn/Exp/458/

标签: IARSTM8
分享给朋友:

“IAR STM8 #pragma optimize 指令” 的相关文章

BOS自定义单据对应模块后台查找

bos数据大量更改新增之后,会出现数据存放位置忘记的情况,下面为单据及单据转换后台查询对应模块的语句,如有需要可参考查询--自定义单据忘记存放在哪个模块可使用以下语句进行查询SELECT it.FID,it.FFunctionID as FSubSysID,it.FNa...

Altium pcb文件过大

Altium pcb文件过大

问题描述: 一些Altium Designer设计的文件看上去板子小且走线也不多,但是保存后文件却比较大。 原因: 通常是在PCB中放置了非默认字体的字符。 在软件里面有一个默认的选项“Embed  TrueType Fonts inside PCB Doc...

SharePoint 2010打开网页超慢(加载服务过多)

SharePoint 2010打开网页超慢(加载服务过多)

问题描述: 安装完sharepoint server 2010 后,无论打开网站或者打开管理中心,都发觉每点击一个连接,都要等十几甚至二十秒以上才打开网页。 原因: 默认启动很多服务和功能,可根据需要关闭掉一些不需要的服务与功能。 具体操作:进入【管理中心】-》【管理服务器场功能】,找到&ldquo...

图像不能包含 alpha 通道或透明度

将app上传到应用市场时,都会要求提供app图标,但是上传时,有时候就会碰到: “图像不能包含 alpha 通道或透明度” 如何解决这个问题呢? 将图片另存为 jpeg格式。如果要求png格式,那么再将jpeg转成png, 使用工具:windows自带的画图。...

水晶报表的文本对象中怎么插入换行符

水晶报表的文本对象中如何插入换行符?我的文本对象要显示的值是从RichTextBox中读出来的,但文本对象不能显示“\n”,怎么让文本对象换行呢?------解决方案--------------------1:不要用文本对象,用公式2:把\n替换成水晶报表里的换行符号Replace(字段,'...

OKI单片机——ML610Q4XX PWM

OKI单片机——ML610Q4XX PWM

  /***********************************************/ * @brief 初始PWM 引脚 * @details /***********************************************/ void P43_Init...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。