[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] Space optimisation for PSTR()
From: |
Bernard Fouché |
Subject: |
RE: [avr-gcc-list] Space optimisation for PSTR() |
Date: |
Wed, 8 Sep 2004 14:46:12 +0200 |
... [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
- RE: [avr-gcc-list] Space optimisation for PSTR(),
Bernard Fouché <=