[RFC] system_data_types.7: Specify the length modifiers for the variables that have them
Paul Eggert
eggert@cs.ucla.edu
Fri Sep 18 20:24:43 GMT 2020
On 9/18/20 12:54 PM, Alejandro Colomar wrote:
> +for printing
> +.I ptrdiff_t
> +variables.
I suggest saying "values" instead of "variables", here and elsewhere, since
variables need not be involved.
> +.BR %ti
This sort of thing should use ".B" not ".BR". There are multiple instances of this.
> +Glibc provides a length modifier for
> +.I ssize_t
> +for the
> +.BR printf (3)
> +and the
> +.BR scanf (3)
> +families of functions, which is
> +.BR z ;
> +resulting commonly in
> +.B %zd
> +or
> +.BR %zi
> +for printing
> +.I ssize_t
> +variables.
> +Note that POSIX doesn't provide this length modifier,
> +and therefore portable programs should avoid using it.
> +Instead, such programs should cast the value to
> +.IR intmax_t .
POSIX does provide that length modifier; however, it doesn't say it works with
ssize_t. I suggest rewording "Glibc provides a length modifier" to "Glibc and
most other implementations provide a length modifier", and changing the last two
sentences to:
Although
.B z
works
for
.I ssize_t
on Glibc and most other implementations, portable POSIX programs should avoid
it, e.g., by converting to
.I intmax_t
and using its length modifier.
More information about the Libc-alpha
mailing list