[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: source(builtin) and read(2)
From: |
Paul Eggert |
Subject: |
Re: source(builtin) and read(2) |
Date: |
Wed, 04 Apr 2007 09:40:21 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
"Schwarz, Konrad" <address@hidden> writes:
> What is the justification for making the return value of read() have type
> ssize_t?
Again, I wasn't there. But when ssize_t was invented, C89 (and
therefore ptrdiff_t) was not required by POSIX, so I expect the
original motivation was that POSIX wanted a type and could not assume
ptrdiff_t (and couldn't define ptrdiff_t either, due to potential
clashes).
Nowadays it's conventional wisdom that ssize_t must be the same width
as size_t, and I expect that code relies on this even if POSIX doesn't
require it. It's not conventional wisdom that ptrdiff_t must be the
same width as size_t, because implementations may want ptrdiff_t to be
reliable, and in general ptrdiff_t is not reliable unless it's wider
than size_t. So there's still a gap between the two types in
principle, not that I know of any modern implementation where they
actually differ.