[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] Space optimisation for PSTR()
From: |
E. Weddington |
Subject: |
RE: [avr-gcc-list] Space optimisation for PSTR() |
Date: |
Wed, 08 Sep 2004 07:05:56 -0600 |
On 8 Sep 2004 at 14:46, Bernard Fouché wrote:
> ... [snip]
> ... discussion about how to have strings declared only once in flash
> ... memory to spare space.
>
> Just a fix to your proposal
>
> Instead of having:
>
> file text.h:
> ------------------------------------------------------------------
> #include <avr/pgmspace.h>
>
> // Must have a C file with the MAIN_C definition in it.
> #ifdef MAIN_C
> #define global_text(sym, value) char sym[] PROGMEM = value
> #else
> #define global_text(sym, value) extern char sym[] PROGMEM
> #endif
>
> ... [ snip ] ...
> ------------------------------------------------------------------
>
> I think its better to have:
>
> #ifdef MAIN_C
> #define global_text(sym,value) char sym[] PROGMEM = value
> #else
> #define global_text(sym,value) extern char sym[sizeof(value]]
> #endif
>
> This way a file not defining MAIN_C is able to use sizeof() on the
> requested string.
>
> Bernard
Interesting. I'll check it out. Thanks!
Oh, and after looking at the above, there should be a const before the char in
each of the
#defines. I may have accidently left that out.
Eric