|
From: | David Brown |
Subject: | Re: [avr-libc-dev] PSTR() and duplicate strings |
Date: | Wed, 06 Apr 2011 09:00:30 +0200 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 |
On 05/04/2011 20:30, Benoît Ryder wrote:
Thanks for these answers, it is now completely clear for me. Indeed, I checked only the (ROM) size of the final binary, forgetting about .data.There is a "-fmerge-all-constants" flag - it is possible that this will give you the merging you want (though it doesn't seem to have the effect when I tested on a single file).Unfortunately, it does not seem to work. According to gcc's manual -fmerge-all-constants is only a more aggressive version of -fmerge-constants, which is responsible for the optimizations mentioned previously; so it not suprising.
Yes. The big problem with doing such merging is that it is in conflict with a fundamental C requirement - different objects shall always have different addresses. gcc can do quite well at getting around this if you don't look at the addresses of the objects, but in the case of the PSTR macros you /do/ take the addresses of the char arrays. The compiler can only merge the constants if it can guarantee that your code doesn't rely on them being at different addresses, which is not an easy task.
[Prev in Thread] | Current Thread | [Next in Thread] |