What's a good prototype for write(2)?

Doug Gwyn gwyn at smoke.BRL.MIL
Wed Oct 26 19:42:30 AEST 1988


In article <902 at vsi.COM> friedl at vsi.COM (Stephen J. Friedl) writes:
>What is a proper prototype for write(2)?

	extern int write(int, const char *, unsigned);
describes the existing function and should be used if you want to
avoid relying on the automatic parameter conversions that prototypes
provide (in order that your code continue to work on older systems).

>but how does this deal with a successful
>write very near the maximum unsigned value?

You have to cast the result to unsigned before comparing it to the
requested count.  But before you do that, test for -1 (error).

>P.S. - I know that write(2) is not specified in the dpANS.

But it is specified by IEEE 1003.1-1988 (they don't use prototypes).
My copy isn't at hand so I can't check just how it ended up.



More information about the Comp.std.c mailing list