stdarg

Barry Margolin barmar at think.com
Thu Feb 7 15:37:15 AEST 1991


In article <ENAG.91Feb6230643 at holmenkollen.ifi.uio.no> enag at ifi.uio.no (Erik Naggum) writes:
>In article <1991Feb6.171144.7182 at Neon.Stanford.EDU>, Dave Eisen writes:
>> Probably a reasonable decision. But it does make it a pain to deal
>> with the third party software we use that is full of <varargs.h> functions
>> that can take 0 or more arguments.
>How do these functions determine how many arguments to use, and what
>type they are?

Well, consider a function taking a variable number of strings, followed by
a null pointer.  The type is known by definition, and the number of
arguments can be determined by looking at them.

I'm not claiming that this is a good programming style, but an awful lot of
people seem to be assuming that a fixed argument is needed in order to
determine how to process the remaining arguments.  While this style could
easily be replaced with one where there is an initial fixed argument
containing the count of variable arguments, that's more prone to error:
during program maintenance it is likely that an argument will be added but
the argument count could easily be left unchanged.
--
Barry Margolin, Thinking Machines Corp.

barmar at think.com
{uunet,harvard}!think!barmar



More information about the Comp.lang.c mailing list