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

IAR STM8 #pragma optimize 指令

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

参考资料: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 指令” 的相关文章

WinRAR创建自解压程序

WinRAR创建自解压程序

前面提到了用FilePacker来打包文件夹(http://www.xjtudll.cn/Exp/63/),这次介绍的是用WinRAR来创建自解压程序,从而实现发布单文件程序的目的。当然,你也可以另作他用。WinRAR相当普及,几乎人人电脑上都有。如何用WinRAR创建自解压程序呢?且看下面分解。1...

后缀名为.Q的文件为什么用按键精灵无法打开

后缀名为.Q的文件为什么用按键精灵无法打开

问题:.Q文件无法用按键精灵直接打开 解决办法: 将文件放在按键精灵目录 QMScript文件夹里。然后在按键精灵上刷新就有了 以“我的脚本.Q”为例,...

金蝶K3物料在各个订单中如何显示长代码

在系统设置-系统设置-仓库管理-系统设置-供应链整体选项中右边‘基础资料录入与显示采用短代码’的勾去掉...

远程计算机需要网络级别身份验证,而您的计算机不支持该验证

远程计算机需要网络级别身份验证,而您的计算机不支持该验证

问题:使用Win7可以连接服务器的远程桌面,使用XP不行。 服务器是Windows Server 2012 解决办法有两种: 一、修改本地电脑设置 参考资料:https://jingyan.baidu.com/article/380abd0a713f061d91192c63.html 1、点击开始...

Altium Drag妙用——批量添加引脚(PIN)延长导线

Altium Drag妙用——批量添加引脚(PIN)延长导线

使用Altium画单片机相关的原理图的时候,因为要对单片机的引脚添加网表(Netlist),所以必然会用导线将PIN延长,然后加网表。要达到的效果如图所示: 最笨的办法就是:一根线一根线画。这样的话效率很低,典型的浪费时间。有没有更高效的办法呢?答案是肯定的,这就是我标题里提到的Drag的功效。...

IAR Error: Unknown or ambiguous symbol. main解决

IAR Error: Unknown or ambiguous symbol. main解决

网上下载了一个程序(含工程),打开一debug,提示:“Error (col 1): Unknown or ambiguous symbol. main”。经查:设置里没有生成debug information 解决办法: Project->C/C++Compiler-...

发表评论

访客

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