[comp.std.c] open

gwyn@smoke.BRL.MIL (Doug Gwyn) (05/10/89)

In article <1528@mcgill-vision.UUCP> mouse@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

diamond@diamond.csl.sony.junet (Norman Diamond) (05/12/89)

In article <10249@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes:

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

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

You mean implementors should implement new C-language systems
(library etc.) that are not necessarily ANSI conformant?
This is obviously a mistake.  :-)

--
Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.co.jp@relay.cs.net)
  The above opinions are my own.   |  Why are programmers criticized for
  If they're also your opinions,   |  re-implementing the wheel, when car
  you're infringing my copyright.  |  manufacturers are praised for it?

shankar@hpclscu.HP.COM (Shankar Unni) (05/14/89)

> 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.

What would have been really useful is some way to "default" the value
of an argument:

  int open (char *, int, int = 0777);

(a' la' C++).
---
Shankar.