Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!unido!rwthinf!slcdec!hippo!f1.n6000.z2.fidonet.org!p4.f36.n245.z2.fidonet.org!Norbert_Unterberg From: Norbert_Unterberg@p4.f36.n245.z2.fidonet.org (Norbert Unterberg) Newsgroups: comp.windows.ms.programmer Subject: Speaking of _lread (was: Re: _lread doesn't respect O_TEXT) Message-ID: <1645081940@p4.f36.n245.z2.fidonet.org> Date: 4 Jun 91 13:05:00 GMT References: <4190@polari.UUCP> Reply-To: Norbert_Unterberg%p4.f36.n245.z2@hippo.dfv.rwth-aachen.de (Norbert Unterberg) Organization: Point of SoftStream, Dortmund, Germany Lines: 19 Comment-To: Kent_Forschmiedt@f1.n6000.z2.fidonet.org (Kent Forschmiedt) > _lread() ans _lwrite() are misdeclared in windows.h. They are > declared as WORD, which means unsigned int, which means the compiler > believes that they cannot return -1, which they must do to report > an error. I think they are declared correctly, but the documentation is not uptodate. Since _lread/_lwrite can handle nearly 64KB of data, a return value of type int does not allow the function to return the number of read/written bytes, if it is above 32 KB. So the functions return the unsigned number of bytes, or 0xffff if an error occured. If the return type is int, code like if (_lread(file, buffer, n) != n) error(); does not work for n > INT_MAX. Norbert