diff --git a/libraries/AP_Common/AP_Common.h b/libraries/AP_Common/AP_Common.h index 798571be41..98cb5bd618 100644 --- a/libraries/AP_Common/AP_Common.h +++ b/libraries/AP_Common/AP_Common.h @@ -94,8 +94,14 @@ typedef struct { #endif # undef PSTR + /* Need const type for progmem - new for avr-gcc 4.6 */ + # if __AVR__ && __GNUC__ == 4 && __GNUC_MINOR__ > 5 + # define PSTR(s) (__extension__({static const prog_char __c[] PROGMEM = (s); \ + (const prog_char_t *)&__c[0]; })) + #else # define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); \ (prog_char_t *)&__c[0]; })) + #endif #endif // a varient of PSTR() for progmem strings passed to %S in printf() diff --git a/libraries/FastSerial/vprintf.cpp b/libraries/FastSerial/vprintf.cpp index fa435ac54e..898475cc4d 100644 --- a/libraries/FastSerial/vprintf.cpp +++ b/libraries/FastSerial/vprintf.cpp @@ -52,7 +52,12 @@ extern "C" { #undef PROGMEM #define PROGMEM __attribute__(( section(".progmem.data") )) #undef PSTR + /* Need const type for progmem - new for avr-gcc 4.6 */ + #if __GNUC__ == 4 && __GNUC_MINOR__ > 5 +#define PSTR(s) (__extension__({static const prog_char __c[] PROGMEM = (s); &__c[0];})) + #else #define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); &__c[0];})) + #endif #ifdef GETBYTE #undef GETBYTE