<varargs.h> vs. function prototypes
Tony L. Hansen
hansen at pegasus.att.com
Wed Jun 19 00:58:23 AEST 1991
< From: markhall at pyrps5.pyramid.com (Mark Hall)
< #ifdef __STDC__
< void foo(char *format, ...)
< #else
< void foo(format, va_alist) char *format; va_dcl
< #endif
< {
< va_list ap;
< #ifdef __STDC__
< va_start(ap,format);
< #else
< va_start(ap);
< #endif
<
< [ ... rest of stuff the same ... ]
< }
The above form for <varargs.h> usage is wrong. The documentation, and some
implementations, REQUIRE you to declare the function as:
void foo(va_alist) va_dcl
and then pick off the fixed arguments using va_arg:
char *format;
format = va_arg(ap,char*);
Any other usage is non-portable (as portable as you can be using varargs.h,
that is. :-) )
Tony Hansen
hansen at pegasus.att.com, tony at attmail.com
att!pegasus!hansen, attmail!tony
More information about the Comp.std.c
mailing list