svn commit: r228625 - head/usr.bin/csup
Bruce Evans
brde at optusnet.com.au
Sun Dec 18 08:14:19 UTC 2011
On Sun, 18 Dec 2011, Dimitry Andric wrote:
> On 2011-12-18 00:49, mdf at 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
More information about the svn-src-head
mailing list