Variable argument lists.

Karl Heuer karl at haddock.ISC.COM
Fri May 13 05:54:06 AEST 1988


In article <11453 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
>[C is not typeless; its values are really <type,value> pairs; ignoring the
><type> part is dangerous.]  And this is the problem with va_count(): even if
>it uses a `hidden argument' (something other than the [VMS] return byte
>count), it can only tell you how many arguments there were.  It cannot tell
>you their types.  In short, it is not general enough for C.

It couldn't handle polymorphic functions like printf(), but it would still be
useful for monomorphic functions like execl() or multistrcat().  (Using a
sentinel at the end of the list is error-prone, and if the type in question is
not a pointer, there may not be any appropriate out-of-band value to use.
Using an explicit argcount variable is also error-prone ("Computers are much
better than humans at counting"), and nontrivial in the face of #if'd args.)

Actually, va_count() may be more powerful than we need.  We could eliminate
the problem of what the "count" really means; all we really need is a boolean
that will tell us when we're at the end of the arglist.

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



More information about the Comp.lang.c mailing list