Discussion:
[avr-libc-dev] Printf %S printing from PROGMEM not functional, compiler error
Joerg Wunsch
2018-03-10 16:01:22 UTC
Permalink
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
this.
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.
--
cheers, Joerg .-.-. --... ...-- -.. . DL8DTL

http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)
Joerg Wunsch
2018-03-13 10:09:43 UTC
Permalink
Post by Joerg Wunsch
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
this.
Sorry, I've been sick at the weekend, so my previous reply was a
little terse.

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.
Post by Joerg Wunsch
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
logical extension.
--
cheers, Joerg .-.-. --... ...-- -.. . DL8DTL

http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)
Loading...