variable number of arguments

Randy D. Smith smithrd at rtp47.UUCP
Thu Aug 8 21:31:32 AEST 1985


In article <159 at mips.UUCP> sah at mips.UUCP (Steve Hanson) writes:
>One practice in C that is both deeply ingrained in UNIX (e.g. printf, doprnt.c)
>and non-obvious to the reader are functions that take a variable number.
[of arguments]
>
>My questions are:
>  (1) Are these macros being used by developers ?
Yep.
>  (2) What is the reaction to them ?
It works.  The other way doesn't on many implementations.
>  (3) Is old code modified to use them?
Yes.  In particular, I've modified dbx (the 4.2 BSD debugger)
to use varargs with complete success.  I also modified ctrace
(a Sys. V Rel. 2 debugging utility) to use varargs instead of
passing a single argument of whatever type on the calling side,
and expecting a "union { all possible types }" on the called side.
GAK!

I encourage more people to check out the man page for the varargs
package, and to actually use it.  IN PARTICULAR, if you have ever
tried running some arbitrary piece of code on a UNIX (tm of AT&T
Bell Labs) or UNIX-lookalike, had the code to break, then determined
that the UNIX you are using "grows the stack in the ``wrong'' direction",
then consider complaining to the bozo that wrote the non-portable
code rather than considering the UNIX to be brain damaged.

-- 
				Randy D. Smith	(919) 248-6136
			   Data General, Research Triangle Park, NC
			 <the known world>!mcnc!rti-sel!rtp47!smithrd



More information about the Comp.lang.c mailing list