[comp.std.c] Prototypes

rang@cpsin3.cps.msu.edu (Anton Rang) (04/29/89)

Is it possible to declare a prototype with an "optional" final
argument?  I'm trying to do a prototype for BSD's "open", which takes
either 2 or 3 arguments.  At the moment, I have:

	extern int open(char *, int, ...);

Is there any way to limit this to only take 2 or 3 arguments (as
opposed to 2 or more)?

+---------------------------+------------------------+-------------------+
| Anton Rang (grad student) | "VMS Forever!"         | VOTE on	         |
| Michigan State University | rang@cpswh.cps.msu.edu | rec.music.newage! |
+---------------------------+------------------------+-------------------+
| Send votes for/against rec.music.newage to "rang@cpswh.cps.msu.edu".   |
+---------------------------+------------------------+-------------------+

karl@haddock.ima.isc.com (Karl Heuer) (04/30/89)

In article <2775@cps3xx.UUCP> rang@cpswh.cps.msu.edu (Anton Rang) writes:
>I'm trying to do a prototype for BSD's "open"

BSD?  I thought AT&T was to blame for that mistake.

>	extern int open(char *, int, ...);
>Is there any way to limit this to only take 2 or 3 arguments (as
>opposed to 2 or more)?

No.  The prototype you gave is the best possible under the circumstances.
(Except that the first arg should be declared with "const".)

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint

mouse@mcgill-vision.UUCP (der Mouse) (05/10/89)

In article <12864@haddock.ima.isc.com>, karl@haddock.ima.isc.com (Karl Heuer) writes:
> In article <2775@cps3xx.UUCP> rang@cpswh.cps.msu.edu (Anton Rang) writes:
>> I'm trying to do a prototype for BSD's "open"
>>	extern int open(char *, int, ...);
> The prototype you gave is the best possible under the circumstances.
> (Except that the first arg should be declared with "const".)

Every BSD manpage for three-argument open() I've seen doesn't show the
third argument as optional.  (BSD not to be confused with, for example,
Sun, which does show the third argument as optional.)  You'll normally
get away with omitting it (when not including O_CREAT), but that
doesn't make it optional.

Or is it supposed to be optional and the manpage is wrong?

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu