How to Turn Off All Optimizations/Eliminate SP debug info incorrect warning/etc

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to Turn Off All Optimizations/Eliminate SP debug info incorrect warning/etc

ソリューションへジャンプ
2,122件の閲覧回数
YeOldeBDM
Contributor III
Hi. I am using CodeWarrior 3.1 for HCS12.
 
I am having some problems with promotions to longs, the way certain #define's are taken when their size is not specified, etc mysterious results when an unsigned char member of a structure is a multiplicand versus a standalone unsigned char, understanding what is implementation dependent and what is not, AND ALL THAT GOOD STUFF.
 
I am experimenting with various snippets of code, and all too often the optimizations are obfuscating what is observed in the debugger.
 
Is there a way to setup a project so that all optimization is turned off (just for that project) ?
 
If there is no way to localize the compiler settings to that one project, can someone explain to me how to turn off all the optimizations anyway?
 
Thanks
 
ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
1,250件の閲覧回数
CrasyCat
Specialist III
Hello
The symptoms you are describing are not directly related to optimization but rather to ANSI C standard definition.
You say "promotions to longs, the way certain #defines are taken when their size is not specified".
Please remember that ANSI C standard defines that integral promotion rule apply for arithmetic operation which do not involve a long operand.
 
That means if you have an assignment as follows:
  myLong = myInt1*myInt2;
the expression myInt1*myInt2 will be evaluated on 16-bit and then signed extended to 32-bits.
 
To make sure the expression is evaluated on 32-bits, you have to cast one of the operands as a long.
This is done as follows:
  myLong = (long)myInt1*myInt2;
 
for operand defined as macro (in a define), just add the suffix L to the constant to make sure it is interpreted as  a long.
For example
#define myInt1     10L
 
If you really want to disable optimization proceed as follows:
   - Open the project in the IDE
   - Open the Target Settings dialog (Press ALT + F7)
   - Switch to "Compiler for HC12" panel
   - Click on the "Options" button
   - THere are a lot of optimization you can disable there. This will be taken only for the current project.
 
However note that some optimization cannot be disable at al.
I hope this helps.
 
CrasyCat

元の投稿で解決策を見る

0 件の賞賛
返信
1 返信
1,251件の閲覧回数
CrasyCat
Specialist III
Hello
The symptoms you are describing are not directly related to optimization but rather to ANSI C standard definition.
You say "promotions to longs, the way certain #defines are taken when their size is not specified".
Please remember that ANSI C standard defines that integral promotion rule apply for arithmetic operation which do not involve a long operand.
 
That means if you have an assignment as follows:
  myLong = myInt1*myInt2;
the expression myInt1*myInt2 will be evaluated on 16-bit and then signed extended to 32-bits.
 
To make sure the expression is evaluated on 32-bits, you have to cast one of the operands as a long.
This is done as follows:
  myLong = (long)myInt1*myInt2;
 
for operand defined as macro (in a define), just add the suffix L to the constant to make sure it is interpreted as  a long.
For example
#define myInt1     10L
 
If you really want to disable optimization proceed as follows:
   - Open the project in the IDE
   - Open the Target Settings dialog (Press ALT + F7)
   - Switch to "Compiler for HC12" panel
   - Click on the "Options" button
   - THere are a lot of optimization you can disable there. This will be taken only for the current project.
 
However note that some optimization cannot be disable at al.
I hope this helps.
 
CrasyCat
0 件の賞賛
返信