HOWTO: Optimization disable for sections of code

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HOWTO: Optimization disable for sections of code

2,585 Views
CarlFST60L
Senior Contributor II
Wow, no standard font to get me started in the thread? Thats just weird! I even had to setup justification just to start typing in this screen!

Anyway, im pretty new to Codewarrior and C Coding, however, i have 10 years of writing assembly code under my belt

Simple question, how do i disable all optimization for sections of C code. Im debugging code that obviously gets removed by optimization while testing. I just want to tell the compilier, for these lines, dont just compile.

Thanks
Carl


Message Edited by CarlFST60L on 2007-05-23 11:13 AM

Message Edited by CarlFST60L on 2007-05-23 11:17 AM
Labels (1)
0 Kudos
Reply
4 Replies

607 Views
CrasyCat
Specialist III
Hello
 
There is no way to disable all of the optimization.
If compiler removes dead code in a function, just use -Onu. You may also try -O0 (Do not know what it is doing, but could be worth a try).
 
If you want to link functions, which are never used to your executable file, you have to use the ENTRIES block in a .prm file.
 
ENTRIES
// List of functions/variables to link here.
END
 
If this does not help, I need to know which kind of code is removed.
 
CrasyCat
0 Kudos
Reply

607 Views
CarlFST60L
Senior Contributor II
Thanks, for what i was doing this time, it worked, but im sure there will be more optimization problems to come...

I have just finished developing a project in assembly, and thought it would be a great test to right the same code in C before starting my next contract which requires C.

There is no specific code that is a problem, as i am learning, i am continually 'trying' diffrent things, and as its 'dead code' (or what ever) it just dosnt alow me to debug

Just a simple on/off optimization button would be very useful for development/testing (maybe its just me, im know that i am only knew to this, so maybe i will not think otherwise in a few weeks when i know how it all works)




Message Edited by CarlFST60L on 2007-05-23 12:01 PM
0 Kudos
Reply

607 Views
Alban
Senior Contributor II
Hi,

If the code is considered as dead, it is because the compiler didn't see any way to get to it.
I would concentrate on eliminating the ambiguity or mistake rather than disabling the messages and their source. You are likely to get a problem if the compiler flags something like this.

Cheers,
Alban.
0 Kudos
Reply

607 Views
CrasyCat
Specialist III
Hello I completely agree with Alban here. Switching optimization off might give the impression the compiler is generating bad (non-optimal) code. It would probably make more sense to figure out why the code has been removed and fix the source code. CrasyCat
0 Kudos
Reply