stdarg

Stephen Clamage steve at taumet.com
Sat Feb 9 03:24:07 AEST 1991


enag at ifi.uio.no (Erik Naggum) writes:

>I'm left to believe that there is no real use for a (...) construct.

Well, if you mean that allowing a variable number of arguments to a
function is a bad idea, I wouldn't disagree.  But if you mean that it
should be allowed without any special construct such as ..., I disagree
strongly.  The ellipsis notifies the compiler (and a person reading the
program) that special care must be taken in interpreting function
arguments.  In particular, special calling sequences may be required.

On modern architectures, function arguments may be passed in registers,
and the registers used may depend on the argument types.  When the
argument number and types are not known to the called routine, the
arguments must be placed in a location which can be determined by the
called routine.  If notification is not required when a routine takes
a variable number of arguments, the inefficient calling sequence must
be used for *all* routines, when usually very few are variadic.

The <varargs.h> model in Standard C, including a required fixed argument,
was developed to ensure that variadic functions could be implemented on a
wide variety of architectures.
-- 

Steve Clamage, TauMetric Corp, steve at taumet.com



More information about the Comp.lang.c mailing list