Disabling optimization in certain areas

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

Disabling optimization in certain areas

Jump to solution
1,812 Views
Luigi
Contributor III
Hi all,
 
I am using CW for the 9S08AW32 processor.  I want copyright information to be part of the executable code as data.  So, I have an array of characters for copyright information declared as "const char Copyright[] = { "Copyright 2008 ... All rights reserved." };  The problem comes in when the compiler wants to optimize Copyright out since it is not used.  So, to get around the problem, I have a statement in main, "errorcode = Copyright[0];".  My question: is there a way to tell the compiler to NOT optimize out the Copyright variable without using the assignment I made above?  Thanks.
 
Lou
 
Labels (1)
Tags (1)
0 Kudos
1 Solution
466 Views
Navidad
Contributor III
You can tell the linker to consider your object as "root" when building the dependency information. Add the following snippet to your .prm file to do that:

DEPENDENCY
  ROOT Copyright END
END

Alternatively, you can add an "ENTRIES" block to your .prm file:

ENTRIES
  Copyright
END



View solution in original post

0 Kudos
2 Replies
467 Views
Navidad
Contributor III
You can tell the linker to consider your object as "root" when building the dependency information. Add the following snippet to your .prm file to do that:

DEPENDENCY
  ROOT Copyright END
END

Alternatively, you can add an "ENTRIES" block to your .prm file:

ENTRIES
  Copyright
END



0 Kudos
466 Views
Luigi
Contributor III
Thanks!  I will give those a try.  I know it's no big deal to just leave the assignment statement in there, but I thought there must be a cleaner way of doing it.  Appreciated.
 
Lou
 
0 Kudos