[comp.std.c] types of optional arguments in stdarg.h

rbutterworth@watmath.waterloo.edu (Ray Butterworth) (09/06/88)

In article <1067@xyzzy.UUCP>, meissner@xyzzy.UUCP (Michael Meissner) writes:
> Let me mention something that came
> up in our discussion:  Namely that it is desirable that you have two
> different forms of this, one for the times that you want the comma supplied
> if there are extra arguments, and the other for times when you don't want
> the comma.  Otherwise you could get compilation errors if no extra arguments
> were passed.

That reminds me of something I'd like to see as an extension
to the variable argument prototypes in some future version
of the Standard.

extern void func(type1, type2, ...);  /* usual meaning */

extern void func(type1, type2  ...);
                             ^
                             No comma.
The missing comma would indicate that all the optional "..." args
must have the same type as the second argument.

karl@haddock.ima.isc.com (Karl Heuer) (09/08/88)

rbutterworth@watmath.waterloo.edu (Ray Butterworth) writes:
>[proposal for some future version of the Standard:]
>extern void func(type1, type2, ...);  /* usual meaning */
>extern void func(type1, type2  ...);  /* no trailing comma */
>The missing comma would indicate that all the optional "..." args
>must have the same type as the [last declared] argument.

I independently came up with this same idea.  I think the concept is right,
but the syntax is lousy -- it's too easy to add/delete that comma and
accidentally change the meaning of the declaration.

Also, in C++ the comma is optional (Bjarne wanted it to be forbidden, but
X3J11 made him fix it).  It would not be wise to make a syntax change to C
that is in direct conflict with existing practice in C++.

(Meanwhile, lobby your lint vendor for a /*MONOMORPHIC*/ lintpragma that will
check this for you.)

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