Do you use stdarg, varargs or ya-args?

Doug Gwyn gwyn at smoke.brl.mil
Sat May 11 09:30:21 AEST 1991


In article <2755 at muffin.cme.nist.gov> libes at cme.nist.gov (Don Libes) writes:
>All the STDC (-like) compilers I use support varargs.

Not all the standard-conforming compilers that *I* use!

>Yes, programs that use varargs are not conforming, but we (and I'm
>speaking strictly for my coworkers here) are trying for maximal
>portability in unknown environments.  Either there is a curious irony
>here or I don't understand why STDC invented stdarg.

X3J11 invented ,...) and <stdarg.h> because there was a need for them
in some implementation environments, and the <varargs.h> va_start macro
did not have a slot for the crucial "hook" on a known parameter that is
needed by some reasonable implementations.

For portability, you need to code for three environments:
	(a) <stdarg.h> exists; you can rely on this #if __STDC__.
	(b) <varargs.h> exists; you can almost rely on this #if unix.
	(c) neither header exists; you might be able to provide your
	    own implementation of <varargs.h> for such an environment,
	    or you could try pretending that there are more arguments
	    than needed, which is a kludge that works in many cases.



More information about the Comp.lang.c mailing list