Thread View: mod.computers.pyramid
1 messages
1 total messages
Started by chris
Fri, 01 Aug 1986 23:32
Re: another c bug?
Author: chris
Date: Fri, 01 Aug 1986 23:32
Date: Fri, 01 Aug 1986 23:32
68 lines
1808 bytes
1808 bytes
This is not a compiler bug. It is not legal to take the address
of one argument and use that to compute the address of another
argument. It works on all pure stack machines as long as you know
the direction of stack growth. It does not work on mixed stack/register
machines like the Pyramid.
The proper thing to do in larn's case is to use varargs and vprintf.
I am not sure if vprintf is in the `ucb universe' C library, but
vprintf(fmt, args)
char *fmt;
va_list args;
{
_doprnt(fmt, args, stdout);
}
should work (since I know how Pyramid did their varargs). Given
vprintf, change
show_int_args (args)
int args;
{
int *pargs;
int i;
pargs = &args;
while (*pargs != 0)
printf ("%d : ", *pargs++);
printf ("%d\n", 0);
}
to
#include <varargs.h>
show_int_args(va_alist)
va_dcl
{
register int i;
va_list p;
va_start(p);
for (;;) {
i = va_arg(p, int);
if (i == 0)
break;
printf("%d : ", i);
}
printf("0\n"); /* simplified */
va_end(p);
}
/* emulate a standard printf() */
xprintf(va_alist)
va_dcl
{
char *fmt;
va_list p;
va_start(p);
fmt = va_arg(p, char *);
vprintf(fmt, p);
va_end(p);
}
Chris
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads