open() prototype

Doug Gwyn gwyn at smoke.BRL.MIL
Thu May 11 02:00:23 AEST 1989


In article <1528 at mcgill-vision.UUCP> mouse at mcgill-vision.UUCP (der Mouse) writes:
>Or is it supposed to be optional and the manpage is wrong?

The third argument to open() seems to have first showed up in USG UNIX
(e.g. UNIX System III), where it was variadic (required for O_CREAT,
not allowed otherwise).  This was obviously a mistake.

When BSD picked it up, they appear to have documented the third
argument as being always required.  This was obviously a mistake.

IEEE 1003.1 followed the USG UNIX interface, but specified it using
a mixture of old-style and prototype declaration syntax.  This was
obviously a mistake.

The best interpretation is that open() really is a variadic-argument
function, that the third argument is required for O_CREAT and may be
present but is ignored otherwise, and that <fcntl.h> must be included
in applications to obtain the appropriate function declaration.

Implementors should declare open() in <fcntl.h> as follows:

#if __STDC__
	extern int open( const char *, int, ... );
#else
	extern int open();
#endif



More information about the Comp.std.c mailing list