passing variable numbers of arguments
Chris Torek
chris at mimsy.UUCP
Mon Jan 9 11:24:56 AEST 1989
In article <449 at marob.MASA.COM> samperi at marob.MASA.COM (Dominick Samperi)
writes:
>It seems that for the ANSI style varargs (that is, the one requiring
>stdarg.h), at least one explicitly named arg must be included in the
>function definition [to provide an `anchor' for va_start] ....
Correct.
>... how does one define a function with a variable number of args,
>for which there are no explicitly named args?
I find it rather annoying that this is not possible. A routine like
`make-vector', which takes a variable number of pointers and makes a
vector of pointers (with the last signified by a NULL pointer of the
appropriate type) must be written awkwardly instead of in the simple
fashion possible with <varargs.h>.
>Wouldn't it have been reasonable for the standard to specify that the
>compiler should enable the called function to determine the number of
>parameters that were passed ... ?
Possibly. But that is not enough information: one needs not only the
number of parameters, but also their types. It seems to me that doing
half the job (providing the count without the types) would be worse than
doing nothing at all.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list