tech-userlevel archive

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

Re: Defining more PRIxxx macros

On Sat, 17 Jan 2009, Martin Husemann wrote:

> On Sat, Jan 17, 2009 at 10:53:08AM +0200, Alan Barrett wrote:
> >     off_t -> PRIdOFF, PRIiOFF, PRIoOFF, PRIuOFF, ...
> >     [s]size_t -> PRIdSIZE, PRIiSIZE, PRIoSIZE, PRIuSIZE, ...
> Why size_t? C99 has defined formats modifiers for size_t (z) and
> ptrdiff_t (t). So using %zu to print a size_t is more portable than
> "%" PRIuSIZE.

good call

btw just looking at the printf(3) manpage, would the following change be
ok since we do have a signed size type and the note seems unnecessary?


--- /usr/src/lib/libc/stdio/printf.3    2007-07-20 22:18:44.000000000 +0100
+++ printf.3    2009-01-17 12:48:22.000000000 +0000
@@ -362,7 +362,7 @@ conversion:
 .It Cm ll No (ell ell) Ta Vt "long long" Ta Vt "unsigned long long" Ta Vt 
"long long *"
 .It Cm j Ta Vt intmax_t Ta Vt uintmax_t Ta Vt "intmax_t *"
 .It Cm t Ta Vt ptrdiff_t Ta (see note) Ta Vt "ptrdiff_t *"
-.It Cm z Ta (see note) Ta Vt size_t Ta (see note)
+.It Cm z Ta Vt ssize_t Ta Vt size_t Ta Vt "ssize_t *"
 .It Cm q Em (deprecated) Ta Vt quad_t Ta Vt u_quad_t Ta Vt "quad_t *"
@@ -376,20 +376,6 @@ or
 conversion, indicates that the argument is of an unsigned type
 equivalent in size to a
 .Vt ptrdiff_t .
-.Cm z
-modifier, when applied to a
-.Cm d
-.Cm i
-conversion, indicates that the argument is of a signed type equivalent in
-size to a
-.Vt size_t .
-Similarly, when applied to an
-.Cm n
-conversion, it indicates that the argument is a pointer to a signed type
-equivalent in size to a
-.Vt size_t .
 The following length modifier is valid for the
 .Cm a ,

Home | Main Index | Thread Index | Old Index