Calling Varargs Twice on a Sun 3 (MC68020)

Chris Torek chris at mimsy.UUCP
Wed Mar 22 20:50:48 AEST 1989


In article <1698 at spp2.UUCP> simpson at trwarcadia.uucp writes:
>Can anyone tell me the magic incantation to call varargs twice on a Sun 3/60?

There is no such incantation; what you are trying to do is, in general,
impossible.

>b(va_alist)
>va_dcl
>{
	...
>}
>
>/* a() calls b() */
>a(va_alist)
>va_dcl
>{
	...
>    b(va_alist);

What you need to do instead (which is not only possible, but even
portable) is this:

	b(va_alist)
		va_dcl
	{
		va_list ap;

		va_start(ap);
		vb(ap);
		va_end(ap);
	}

	vb(ap)
		va_list ap;
	{
		...
	}

	a(va_alist)
		va_dcl
	{
		va_lits ap;

		va_start(ap);
		vb(ap);
		...

This is why v*printf() exist.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.wizards mailing list