Is there any way to temp switch off dead code elimination via #pragma?

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

Is there any way to temp switch off dead code elimination via #pragma?

ソリューションへジャンプ
1,348件の閲覧回数
Koyuki
Contributor I
I'm using HCS12, and for some reason I need to put a bunch of global variables into the CONST_SEG, hence I define them as "const". Those variables are actually referred via API functions, hence within the project they are only assigned with initial values. But I don't want the CodeWarrior to eleminate them during optimization, so I declare them as "extern" in some header file, or define them as "volatile". But this looks not quite good actually, for the modification of these variables are via some hardware path, not the normally way of global variable usage. So I wanna try use some #pragma to switch off the code optimization only on these variables. Is it possible? If so, which #pragma shall I use then?
ラベル(1)
タグ(1)
0 件の賞賛
1 解決策
616件の閲覧回数
Nouchi
Senior Contributor II
Hi,

The best way to force linker to link unused variables, is probably to add the name of your variable in ENTRIES section of your prm file:
in your C file:
const char yourVar1[10] = "Your data";


in your prm file below NAME section:
ENTRIES
yourVar1, yourVar2, ....
END


Emmanuel

元の投稿で解決策を見る

0 件の賞賛
1 返信
617件の閲覧回数
Nouchi
Senior Contributor II
Hi,

The best way to force linker to link unused variables, is probably to add the name of your variable in ENTRIES section of your prm file:
in your C file:
const char yourVar1[10] = "Your data";


in your prm file below NAME section:
ENTRIES
yourVar1, yourVar2, ....
END


Emmanuel
0 件の賞賛