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

IAR STM8 #pragma optimize 指令

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

参考资料: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://xjtudll.cn/Exp/458/

标签: IARSTM8
分享给朋友:

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

sql server 2008提示“列名无效”,但是能正常查询

在SQLServer2008中,当设计(修改)表结构之后,再用SQL语句时,列名会显示无效,但执行可以通过.原因是SQL Server的intellisense(智能感知功能)需要重新整理一下,用快捷键Ctrl+Shift+R即可 归根结底是智能提示出了问题,用了缓存。...

晶振的等效电路(转载)

晶振的等效电路(转载)

http://blog.sina.com.cn/s/blog_a20257d80102w7y4.html 1 晶振的等效电气特性 (1) 概念 [1] 晶片,石英晶体或晶体、晶振、石英晶体谐振器 从一块石英晶体上按一定方位角切下薄片。 [2] 晶体振荡器 在封装内部添加IC组成振荡电路的晶...

Xcode5 Version与Build设置

Xcode5 Version与Build设置

在ios中,有两种version,一种是 CFBundleVersion ("Bundle Version"),也就是我们看到的Version,另一种是CFBundleShortVersionString ("Bundle version string, short&q...

CrystalDecisions.Windows.Forms.CrystalReportViewer.DisplayGroupTree”已过时

问题:早期工程升级到VS2010 提示: CrystalDecisions.Windows.Forms.CrystalReportViewer.DisplayGroupTree”已过时 解决办法: this.crystalReportViewer1.DisplayGroupTree =...

Keil MDK 查看局部变量提示<not in scope>

Keil MDK 查看局部变量提示

现象: 在进行STM32开发的时候出现了,调试代码,添加变量Watch时,显示not in scope。 处理方式: 因为代码开了优化的处理,把优化改到Level0,就可以解决问题。...

如何给程序添加超大图标(EXE大尺寸图标)

如何给程序添加超大图标(EXE大尺寸图标)

要点:1、制作多分辨率ICON文件2、清空图标缓存,使图标文件生效 自己写的程序,如果更换了图标,编译出来,超大图标显示就会发现图标并没有跟着放大。那么问题来了,就换个图标效果就不同了,很明显时图标有问题。用eXeScope打开vs2013编译出来的MFC对话框程序可以看到如下图:这不止一...

发表评论

访客

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