Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnewsm!cbnewsk!pegasus!hansen From: hansen@pegasus.att.com (Tony L. Hansen) Newsgroups: comp.std.c Subject: Re: vs. function prototypes Keywords: usage Message-ID: <1991Jun18.145823.2512@cbnewsk.att.com> Date: 18 Jun 91 14:58:23 GMT References: <25353@oolong.la.locus.com> <159364@pyramid.pyramid.com> Sender: hansen@cbnewsk.att.com (tony.l.hansen) Distribution: na Organization: AT&T Bell Laboratories Lines: 34 < From: markhall@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 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@pegasus.att.com, tony@attmail.com att!pegasus!hansen, attmail!tony