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

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

[avr-libc-dev] [bug #34680] PSTR() should declare a const variable


From: Volker Kuhlmann
Subject: [avr-libc-dev] [bug #34680] PSTR() should declare a const variable
Date: Sat, 29 Oct 2011 04:20:04 +0000
User-agent: Mozilla/5.0 (compatible; Konqueror/4.6; Linux) KHTML/4.6.0 (like Gecko) SUSE

URL:
  <http://savannah.nongnu.org/bugs/?34680>

                 Summary: PSTR() should declare a const variable
                 Project: AVR C Runtime Library
            Submitted by: vok
            Submitted on: Sat 29 Oct 2011 17:20:03 NZDT
                Category: Header
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Header files
                  Status: None
        Percent Complete: 0%
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 1.7.1
           Fixed Release: None

    _______________________________________________________

Details:

avr/pgmspace.h defines

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

which places the variable into read-only (program flash) memory. This should
be marked as const to indicate that the variable will not change.

Because of a gcc bug (4.2? - 4.5) it's necessary to redefine PROGMEM to
#define PROGMEM __attribute__(( section(".progmem.data") ))
to achieve the same effect but without the bogus warning from gcc.
This definition gives a linker error when mixing const and non-const variables
in the same section. Placing the const variables into ".progmem.data" and the
non-const into ".progmem.datanotreadwriteafterall" works with the same effect,
but I don't see how to do that automatically.

See bug #28837, and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734
So to make this all work with correctly programmed source that uses const,
make PSTR const as well, which it should have been in tne first place.




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?34680>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

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