Setting the optimization on a single source file.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Setting the optimization on a single source file.

跳至解决方案
2,205 次查看
MTBer
Contributor I
I would like to find out how to set the optimization of a single source file in my project for speed and leave the rest the same as it currently stands (size). 
 
I have searched through this forum and help files and already spend hours on this.  Searched all the settings in the IDE etc.  I'm dying here
 
It's for an HCS12XE device and Codewarrior version 4.6.  Hope this is enough info.
 
Then, off the topic, my email address changed a few years back, but are still forwarded to my new address.  One day soon, the alias will be killed and then I won't be able to log into this forum anymore.  Does anyone know how to change this email address?
 
Thanks in advance for all you great answers,
MTBer
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,214 次查看
CrasyCat
Specialist III
Hello
 
Well this can work for single functions as well.
 
Just enclose the function (or functions) you want to optimize for execution time between the 2 pragmas.
 
Option is activated with pragma OPTION ADD and desactivated with pragma OPTION DEL.
 
So you can decide whether you want to use it for 1 function, a set of functions or the whole module :smileywink:
 
CrasyCat

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,214 次查看
CrasyCat
Specialist III
Hello
 
In order to activate a compiler option for a single module you can use the pragma OPTION.
 
Put following line before the implementation of the first function in the module
#pragma OPTION ADD OptimizeTime "-Ot"
 
Place following line at the end of the module
 
#pragma OPTION DEL OptimizeTime
 
In order to get your email address changed you need to submit a Service Request with Categorie = Web and Topic = Email Address Change

Click here to submit a service request.
CrasyCat
1,214 次查看
MTBer
Contributor I
Hi CrasyCat,
 
Thanks a lot for your response.  I have tried it, but unfortunately my code jump from 10k to 40k for this source file and now I am struggling to make it fit.
 
This will only work down to a function level or can I use it inside a function as well?
 
Thanks again,
MTBer
0 项奖励
回复
1,215 次查看
CrasyCat
Specialist III
Hello
 
Well this can work for single functions as well.
 
Just enclose the function (or functions) you want to optimize for execution time between the 2 pragmas.
 
Option is activated with pragma OPTION ADD and desactivated with pragma OPTION DEL.
 
So you can decide whether you want to use it for 1 function, a set of functions or the whole module :smileywink:
 
CrasyCat
0 项奖励
回复