Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Dec 2011 19:14:15 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Dimitry Andric <dim@freebsd.org>
Cc:        svn-src-head@freebsd.org, mdf@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r228625 - head/usr.bin/csup
Message-ID:  <20111218184908.H1383@besplex.bde.org>
In-Reply-To: <4EED2D66.3000304@FreeBSD.org>
References:  <201112171314.pBHDEjtQ060509@svn.freebsd.org> <CAMBSHm9cBbCxZ9MvgPvKgYfSxPSpeofgTq0NnJo=e3tR5idxEQ@mail.gmail.com> <4EED0F99.2020306@FreeBSD.org> <CAMBSHm9=0%2BZ%2BC687097WW_mGaNUpJ7Tbo7SZa4XLr7g0L2ecOQ@mail.gmail.com> <4EED2D66.3000304@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 18 Dec 2011, Dimitry Andric wrote:

> On 2011-12-18 00:49, mdf@FreeBSD.org wrote:
> ...
>> Also, long long is a bit of a hack that came in before C99
>> standardized on a few wider types, and the PRIu64 macros are really
>> hideous.
>
> I agree they're ugly, but C99 should simply have defined length
> modifiers for int64_t and friends, then the PRI macros could have been
> avoided.  (Although not without backwards compatibility problems, but
> you would have those anyway. :)

Length modifiers for everything would have required more compiler and
library support, and more excessive invention of new interfaces, and
are almost as bad as PRI* anyway.  Both require the programmer to know
the type of a foo_t and hard-code this into the printf format.

A good way would be %I or %\DWIM which is replaced in the string literal
by the appropriate length modifier.  (The compiler knows the correct
length modifier after doing the same analysis as for warning about the
modifier being wrong, and only has to tell the libary instead of the
programmer about this.)  Something different is needed for message
catalogs.  I've seen propsed that variadic functions should pass type
info for all args, but this would break ABIs.  It also takes more
space and time than translating %I to a minimal modifier (usually
a single letter).

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111218184908.H1383>