[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] Printf %S printing from PROGMEM not functional, compi

From: Joerg Wunsch
Subject: Re: [avr-libc-dev] Printf %S printing from PROGMEM not functional, compiler error
Date: Tue, 13 Mar 2018 11:09:43 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

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
> 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.

> > 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

Never trust an operating system you don't have sources for. ;-)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]