avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] [bug #28837] using PSTR with c++ produces warnings


From: Dave Hylands
Subject: Re: [avr-libc-dev] [bug #28837] using PSTR with c++ produces warnings
Date: Mon, 8 Feb 2010 01:03:42 -0800

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/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]