Browse Source

added -Wformat in Arduino.mk

when building with 'make' we get warnings related to printf() format
strings

git-svn-id: https://arducopter.googlecode.com/svn/trunk@1798 f9c3cf11-9bcb-44bc-f272-b75c42450872
mission-4.1.18
tridge60@gmail.com 14 years ago
parent
commit
a633617eef
  1. 5
      libraries/AP_Common/AP_Common.h
  2. 2
      libraries/AP_Common/Arduino.mk
  3. 4
      libraries/AP_Common/menu.cpp

5
libraries/AP_Common/AP_Common.h

@ -84,6 +84,11 @@ typedef struct { @@ -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);

2
libraries/AP_Common/Arduino.mk

@ -159,7 +159,7 @@ endif @@ -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

4
libraries/AP_Common/menu.cpp

@ -44,7 +44,7 @@ Menu::run(void) @@ -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) @@ -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

Loading…
Cancel
Save