Re: Printf %S printing from PROGMEM not functional, compiler error
As Joerg Wunsch wrote:
> > But I get the following compiler error:
> > error: format '%S' expects argument of type 'wchar_t*', but argument 2
> > has type 'const char*' [-Werror=format=]
> > printf("%S:%u\n", name, i);
> Then do as suggested, and turn off compiler warnings (and -Werror) for
Sorry, I've been sick at the weekend, so my previous reply was a
In general, the C standard reserves lowercase formatting letters for
future standardized conversions, but leaves other characters (so
namely uppercase letters) for "extensions".
Thus, avr-libc's use of %S for progmem strings is fully standards
compliant. It's GCC here that applies wrong assumptions. It would be
cool if we could somehow "tune" that in the avr-libc printf()
prototype (to avoid the pointless warning), but I'm not enough of a
GCC expert on that.
> > And "just for fun" I would like to know how to print wide characters
> You can't. avr-libc doesn't implement wide chars in any way.
The standard's format specifier for a wide character string is "%ls".
That's why GCC's notion of %S is just another kind of an extension to
the standard only. We've picked %S for progmem strings, since we
don't support wide characters anyway, and it seemed to be the most