AP_Common: PSTR def has specific version for avr-gcc 4.6 compatibility

* Also a small change in FastSerial/vprintf.cpp, which duplicates the
  PSTR definition
* Won't effect others using earlier versions of avr-gcc
This commit is contained in:
Pat Hickey 2012-10-15 19:23:15 -07:00
parent 6b6e580a13
commit def4ffbe86
2 changed files with 11 additions and 0 deletions

View File

@ -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()

View File

@ -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