diff --git a/libraries/AP_Common/AP_Common.h b/libraries/AP_Common/AP_Common.h index d65245f17c..b93c862eb1 100644 --- a/libraries/AP_Common/AP_Common.h +++ b/libraries/AP_Common/AP_Common.h @@ -84,6 +84,11 @@ typedef struct { (prog_char_t *)&__c[0];})) #endif +// a varient of PSTR() for progmem strings passed to %S in printf() +// this gets the gcc __format__ checking right +#define FPSTR(s) (wchar_t *)(s) + + static inline int strcasecmp_P(const char *str1, const prog_char_t *pstr) { return strcasecmp_P(str1, (const prog_char *)pstr); diff --git a/libraries/AP_Common/Arduino.mk b/libraries/AP_Common/Arduino.mk index 084580beba..6f5e956dfa 100644 --- a/libraries/AP_Common/Arduino.mk +++ b/libraries/AP_Common/Arduino.mk @@ -159,7 +159,7 @@ endif # Tool options # DEFINES = -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERS) -OPTFLAGS = -Os +OPTFLAGS = -Os -Wformat DEPFLAGS = -MD -MT $@ # XXX warning options TBD diff --git a/libraries/AP_Common/menu.cpp b/libraries/AP_Common/menu.cpp index 499e3ff968..a4ea664a4f 100644 --- a/libraries/AP_Common/menu.cpp +++ b/libraries/AP_Common/menu.cpp @@ -44,7 +44,7 @@ Menu::run(void) // loop reading characters from the input len = 0; - Serial.printf("%S] ", _prompt); + Serial.printf("%S] ", FPSTR(_prompt)); for (;;) { c = Serial.read(); if (-1 == c) @@ -127,7 +127,7 @@ Menu::_help(void) Serial.println("Commands:"); for (i = 0; i < _entries; i++) - Serial.printf(" %S\n", _commands[i].command); + Serial.printf(" %S\n", FPSTR(_commands[i].command)); } // run the n'th command in the menu