This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: comparisons..
On Thu, Jul 13, 2000 at 05:30:30PM -0700, Russ Allbery wrote:
> I don't think a lot of C programmers pay enough attention to signed vs.
> unsigned issues, including a lot of interface designers. Note, for
> example, the interface to write:
>
> ssize_t write(int fildes, const void *buf, size_t nbyte);
>
> What *do* you return if you can successfully write out as one block more
> data than will fit in the range of ssize_t, but that will fit into size_t
> (which is normally twice as large on the positive end)? :)
-1 with errno set to EINVAL (and do no writing).
In this one small case, I think Microsoft actually got the interface right,
since they separate # of bytes written from the error value, so for example,
you can say that you wrote 2 megabytes of data before the error occurred.
--
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work: meissner@redhat.com phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org fax: +1 978-692-4482