Varargs in C - (nf)

Kevin Martin kpmartin at watmath.UUCP
Thu Aug 30 04:02:40 AEST 1984


>This is fundamentally the same as the varargs used in 4.2 but is
>slightly different in that a pointer to the current stack frame
>can be passed to another function.
I think the 4.2 varargs does let you pass such a pointer to another
function. You declare the callee as accepting a parameter of type
'va_list', and it should be able to use this variable just like the
variables of type 'va_list' in the original (varargs) function.

>Note that there are two items which I have not included in this
>specification.  One is a simple method of getting the number of
>arguements passed.  The other item is a method of determining
>the types of the arguements passed.  I feel that both of these
>are bad since they force the information to be passed around all
>of the time
>Perry
>convex!smu!pedz

Many stack implementations already support an argument count of some
sort. Sometimes it is an actual word or byte count. Other times, it is
the count of passed values (i.e. a large struct passed by value only counts
as one). The way to use this portably is to have some way of testing
the pointer-to-next-arg for being beyond the last argument, sort of like
an eof function.
As for type information for each argument, it is not clear that this is
useful in most cases... The callee would either ignore it, or blow up if
it is wrong (at great expense of decoding the type info...).

Basically, there is a vast difference between the ratios of
(cost of implementation + cost of use) :: advantage of feature
for having an arg count and for having arg type info.
                       Kevin Martin, UofW Software Development Group



More information about the Comp.lang.c mailing list