THINK C4 stdio gotchas

Karl Heuer karl at haddock.ima.isc.com
Sun May 27 08:40:49 AEST 1990


In article <54861 at microsoft.UUCP> t-jlee at microsoft.UUCP (Johnny LEE) writes:
>THINK C has size_t as an unsigned long and
>    int read (int fd, char *buf, unsigned int n);
>So the number of chars you can request and the number returned as read
>won't be equal for values>32767.
>In fact, you can request 65535 (or is it 32768?) and if you get
>all 65535 chars, your return value will look like an EOF.

Actually a read error rather than an EOF.  Use of errno can disambiguate this
case.

>Makes read() kinda limited.

Yes.  The correct hack is for such implementations to supply a separate
function, perhaps named lread(), that does the right thing.

Karl W. Z. Heuer (karl at ima.ima.isc.com or harvard!ima!karl), The Walking Lint
Followups to comp.lang.c only.



More information about the Comp.lang.c mailing list