[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: printing size_t variables
From: |
Mark D. Baushke |
Subject: |
Re: printing size_t variables |
Date: |
Sat, 02 Sep 2006 11:29:59 -0700 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Eric Blake <address@hidden> writes:
> Should we have a gnulib module for *printf that
> allows us to use the POSIX-mandated
> printf("%zu", (size_t)1) modifier for size_t
> variables? Or what is the current recommended
> practice for printing size_t?
Hmmm... if a gnulib module for *printf were
created, it should probably implement the full
set of POSIX format and modifier characters.
For example,
The Open Group Base Specifications Issue 6
IEEE Std 1003.1, 2004 Edition
http://www.opengroup.org/susv3xsh/printf.html
mentions a few modifiers that are not yet well
deployed on most boxes I use:
j Specifies that a following d, i, o, u, x,
or X conversion specifier applies to an
intmax_t or uintmax_t argument; or that a
following n conversion specifier applies
to a pointer to an intmax_t argument.
z Specifies that a following d, i, o, u, x,
or X conversion specifier applies to a
size_t or the corresponding signed integer
type argument; or that a following n
conversion specifier applies to a pointer
to a signed integer type corresponding to
a size_t argument.
t Specifies that a following d, i, o, u, x,
or X conversion specifier applies to a
ptrdiff_t or the corresponding unsigned
type argument; or that a following n
conversion specifier applies to a pointer
to a ptrdiff_t argument.
I would not mind seeing both the j and z modifiers
generally implemented. However, as Bruno mentions,
this would likely be a fair amount of overhead just
for those few format characters. I think casting is
good enough for now.
-- Mark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (FreeBSD)
iD8DBQFE+c2nCg7APGsDnFERAkrCAKDZpvCaw3UytXe1hpeIuP4UjiUZZgCg58Gr
0lMK1NaDPXgGG0e8cCW2TPQ=
=LT0H
-----END PGP SIGNATURE-----