mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
Add format attributes to printf and printf_P. The latter is a bit wishful as gcc isn't smart enough to deal with what PSTR does, but with some other hackery this can be used to generate useful warnings.
Add a workaround for a GCC bug that generates spurious warnings when PSTR() is used. git-svn-id: https://arducopter.googlecode.com/svn/trunk@901 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
parent
906239160d
commit
f30bf9cab7
@ -22,11 +22,14 @@ public:
|
||||
// Stream extensions
|
||||
void print_P(const char *);
|
||||
void println_P(const char *);
|
||||
void printf(const char *, ...);
|
||||
void printf_P(const char *, ...);
|
||||
void printf(const char *, ...)
|
||||
__attribute__ ((format(__printf__, 2, 3)));
|
||||
void printf_P(const char *, ...)
|
||||
__attribute__ ((format(__printf__, 2, 3)));
|
||||
|
||||
private:
|
||||
void _vprintf(unsigned char, const char *, va_list);
|
||||
void _vprintf(unsigned char, const char *, va_list)
|
||||
__attribute__ ((format(__printf__, 3, 0)));
|
||||
};
|
||||
|
||||
#endif // __BETTERSTREAM_H
|
||||
|
@ -72,6 +72,10 @@ extern "C" {
|
||||
})
|
||||
*/
|
||||
|
||||
// Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734
|
||||
#undef PSTR
|
||||
#define PSTR(s) (__extension__({static prog_char __c[] = (s); &__c[0];}))
|
||||
|
||||
#define FL_ZFILL 0x01
|
||||
#define FL_PLUS 0x02
|
||||
#define FL_SPACE 0x04
|
||||
@ -365,6 +369,7 @@ BetterStream::_vprintf (unsigned char in_progmem, const char *fmt, va_list ap)
|
||||
goto str_lpad;
|
||||
|
||||
case 'S':
|
||||
pgmstring:
|
||||
pnt = va_arg (ap, char *);
|
||||
size = strnlen_P (pnt, (flags & FL_PREC) ? prec : ~0);
|
||||
flags |= FL_PGMSTRING;
|
||||
|
Loading…
Reference in New Issue
Block a user