problem with varargs.h in Xenix 2.3.3
Aryeh M. Weiss
aryeh at eddie.mit.edu
Thu Apr 25 23:39:20 AEST 1991
In article <6596 at cactus.org> statham at cactus.org (Perry L. Statham) writes:
>
>/*
>Can anyone tell me why this program does not compile and how to fix it.
>
>Compiler Message:
> testprog.c(19) : error 65: 'va_alist' : undefined
>
...
>void sceprintf( format, ... )
>char *format;
>{
> FILE *log;
> va_list argptr;
>
> if ((log = fopen("logfile","a+")) != NULL) {
> va_start(argptr);
> vfprintf(log,format,argptr);
> va_end(argptr);
> fclose(log);
> }
>}
There are two implementations of ``varargs'' in Xenix.
The header <varargs.h> is for K&R coding styles while <stdarg.h>
is for ANSI coding style. The va_start is defined differently in
the two styles. Since you are using an almost ANSI
coding style you could try the following:
#include <stdarg.h>
void sceprintf(char *format, ... )
{
FILE *log;
va_list argptr;
if ((log = fopen("logfile","a+")) != NULL) {
va_start(argptr,format); /* Makes argptr point to 1st argument
AFTER format */
vfprintf(log,format,argptr);
va_end(argptr);
fclose(log);
}
}
For K&R coding style use:
#include <varargs.h>
void sceprintf(format, va_alist)
char *format; va_dcl /* NO semicolon! */
{
FILE *log;
va_list argptr;
if ((log = fopen("logfile","a+")) != NULL) {
va_start(argptr); /* Makes argptr point to va_alist */
vfprintf(log,format,argptr);
va_end(argptr);
fclose(log);
}
}
More information about the Comp.unix.xenix.sco
mailing list