passing variable numbers of arguments

Doug Gwyn gwyn at smoke.BRL.MIL
Mon Jan 9 15:55:12 AEST 1989


In article <6898 at june.cs.washington.edu> ka at june.cs.washington.edu (Kenneth Almquist) writes:
>The manual page for varargs doesn't say anything about the effects of
>passing the va_list variable to another routine.

The varargs documentation left a lot unspecified, and consequently some
implementations indeed will not do the expected thing when you try to
pass a va_list to a subfunction.  However, such implementations need to
fix this anyway for their stdarg (ANSI C) version, and probably at the
same time their varargs macros can be fixed.  Many vendors already have
done so, motivated perhaps more by SVID compliance than anything else.

>Perhaps the definition of the stdarg mechanism is more specific?

Definitely.

>Also, I'm curious about why Ansi C uses the stdarg mechanism instead of
>varargs.  I would think that varargs would be easier to implement.

To the contrary, on some architectures <varargs.h> was much harder to
implement than <stdarg.h>.  I collected input from many C implementors
on behalf of X3J11, and had extended discussions about variable
arguments with several.  I believe <stdarg.h> is reasonable.



More information about the Comp.lang.c mailing list