Hi,

> warning: only initialized variables can be placed into program memory area
>
> this seems to be a regressiong, because it happens with code, that compiled
> about a year ago (no idea which version, maybe ~2007) without these warnings.
>
> this was discussed in the ML 2009/12:
> http://lists.gnu.org/archive/html/avr-gcc-list/2009-12/msg00016.html
>
> locally redefining...
> #undef PROGMEM
> #define PROGMEM __attribute__(( section(".progmem.data") ))
>
> #undef PSTR
> #define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s);
> &__c[0];}))
> ... seems to fix it.
>
> what's the "correct" approach to handle this?

I created a header file, which I called pgmspace-fix.h which contains
the following:

#if !defined( PGMSPACE_FIX_H )
#define PGMSPACE_FIX_H

#include <avr/pgmspace.h>

#define PROGMEM_SECTION __attribute__(( section(".progmem.data") ))

#undef PSTR
#define PSTR(s) (__extension__({static char __c[] PROGMEM_SECTION =
(s); &__c[0];}))

#endif  // PGMSPACE_FIX_H

I then make my source files #include "pgmspace-fix.h"

When the problem eventually gets resolved, I can just change
pgmspace-fix.h to not do anything other than #include <avr/pgmspace.h>

At least this way I don't need to modify any files from the compiler
or runtime library.

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/


_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Reply via email to