How to force a string literal into the Flash?

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

How to force a string literal into the Flash?

1,055件の閲覧回数
bburch
Contributor III

Hi!

I have a requirement to have and embedded copyright string in this C project.  I've tried various things with pragmas, but the string always gets optimized out.

Any wisdom on this topic?

THANKS!

-Ben Burch

BTR Controls, Inc.

タグ(1)
0 件の賞賛
返信
3 返答(返信)

960件の閲覧回数
converse
Senior Contributor V

Simple. Just make it const

e.g.

const char string = “value” ;

0 件の賞賛
返信

960件の閲覧回数
bburch
Contributor III

I thought so too, but that did not do it.  The data segment was shown as dropped in the map file.  This was verified by dumping the binary with "xxd" and examining the text representation of the binary.

What I finally did, and which did work, was to append it to a table that was referenced in the code and which was not eliminated by the linker.  But there must be a good way to do this other than that?  Yes nothing refers to it, but there should be a good way to indicate not to optimize it.

Thanks!

0 件の賞賛
返信

960件の閲覧回数
converse
Senior Contributor V

Well, I expected it to be used!

if you want to stop the linker eliminating an unused data, use

__attribute__((used)) const string = “value”;
0 件の賞賛
返信