Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Spurious diagnostic messages Date: Mon, 27 Jul 2015 08:19:40 -0700 Organization: None to speak of Lines: 31 Message-ID: References: <874mn5ty3y.fsf@kst-u.example.com> <87egm8qis7.fsf@kst-u.example.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="20189"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19aoJ9BJJsqoa5oJvXbmV+D" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:pIwYVF06jkUl90NmOopOAlDuKIY= sha1:86bTPPfHO8QDMDkwLCwbKJY6bK4= Xref: csiph.com comp.lang.c:66444 glen herrmannsfeldt writes: > Bartc wrote: >> On 26/07/2015 23:35, Keith Thompson wrote: [...] >>> "%b" is not currently used, so that would be the >>> obvious solution. > >> %b is supported by lccwin and by Digital Mars C (which was a surprise as >> it's pretty old). > >>> A "#" flag could cause printf to print the "0b" >>> or "0B" prefix; "%#b" could print a "0b" suffix, "%#B" could print a >>> "0B" prefix, and "%b" and "%B" would be identical (unlike "%x" and >>> "%X"). > > Does this # flag exist for %x and %o? Yes. "%#x" adds a "0x" prefix, and "%#o" adds a "0" prefix if it's not already there. I generally don't use the "#" flag myself; I find "0x%x" clearer. But it's in the standard, and conforming implementations must support it. If "%b" were added, not supporting "%#b" would be gratuitously inconsistent. And there's precedent for it; Perl's printf and sprintf functions support "%b" and"%#b". -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"