Disabling optimization in certain areas

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

Disabling optimization in certain areas

跳至解决方案
2,535 次查看
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
 
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,189 次查看
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 项奖励
回复
2 回复数
1,190 次查看
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 项奖励
回复
1,189 次查看
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 项奖励
回复