Xref: utzoo comp.unix.xenix.misc:176 comp.unix.xenix.sco:2328 Newsgroups: comp.unix.xenix.misc,comp.unix.xenix.sco Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!batcomputer!cornell!uw-beaver!mit-eddie!eddie!aryeh From: aryeh@eddie.mit.edu (Aryeh M. Weiss) Subject: Re: problem with varargs.h in Xenix 2.3.3 Message-ID: <1991Apr25.133920.15363@eddie.mit.edu> Summary: varargs.h for K&R , stdarg.h for ANSI Keywords: xenix varargs 2.3.3 compiler c Sender: news@eddie.mit.edu (Usenet News) Organization: MIT EE/CS Computer Facilities, Cambridge, MA References: <6596@cactus.org> Distribution: usa Date: Thu, 25 Apr 91 13:39:20 GMT Lines: 61 In article <6596@cactus.org> statham@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 is for K&R coding styles while 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 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 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); } }