How to force a string literal into the Flash?

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

How to force a string literal into the Flash?

1,168 Views
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.

Tags (1)
0 Kudos
Reply
3 Replies

1,073 Views
converse
Senior Contributor V

Simple. Just make it const

e.g.

const char string = “value” ;

0 Kudos
Reply

1,073 Views
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 Kudos
Reply

1,073 Views
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 Kudos
Reply