Calling Varargs Twice on a Sun 3 (MC68020)

simpson at trwarcadia.uucp simpson at trwarcadia.uucp
Wed Mar 22 04:39:24 AEST 1989


Can anyone tell me the magic incantation to call varargs twice on a Sun 3/60?
I don't know the format of the stack and I don't have a Motorola manual.
Please don't flame me for non-portability.  What I want to do is this
(which only gives me the first argument):

#include <stdio.h>
#include <varargs.h>

b(va_alist)
va_dcl
{
    char *s1, *s2;
    va_list ap;
    
    va_start(ap);
    s1 = va_arg(ap, char *);
    s2 = va_arg(ap, char *);
    printf("b(): s1=%s, s2=%s\n", s1, s2);
    va_end(ap);
}

/* a() calls b() */
a(va_alist)
va_dcl
{
    char *s1, *s2;
    va_list ap;

    va_start(ap);
    s1 = va_arg(ap, char *);
    s2 = va_arg(ap, char *);
    printf("a(): s1=%s, s2=%s\n", s1, s2);
    b(va_alist);
    va_end(ap);
}

main()
{
    static char *s1 = "Hello";
    static char *s2 = "There";

    a(s1, s2);
    exit(0);
}
	Scott Simpson
	TRW Space and Defense Sector
	oberon!trwarcadia!simpson  		(UUCP)
	trwarcadia!simpson at oberon.usc.edu	(Internet)



More information about the Comp.unix.wizards mailing list