Re: [PATCH 1/2] system_data_types.7: Document size_t

Joseph Myers
2020-09-30T15:57:53Z

On Fri, 18 Sep 2020, Paul Eggert wrote:

> On 9/18/20 7:34 AM, Florian Weimer via Libc-alpha wrote:
> > the length modifier for printf and scanf is z, commently used as
> > %zu or %zx (%zd is for ssize_t).
>
> While %zd works for ssize_t in glibc, POSIX doesn't guarantee that it'll work,
> as ssize_t might not have the same width as size_t. (If memory serves this
> goes back to the bad old days when size_t was 64 bits and ssize_t 32 bits on
> some platforms.) So if we document %zd we should say it's a GNU extension to
> POSIX, or something like that.

%zd is for the signed type corresponding to size_t; that's in ISO C. The
GNU extension would be a guarantee that ssize_t is the signed type
corresponding to size_t (if we do guarantee that).

--
Joseph S. Myers
joseph@codesourcery.com