Article View: comp.std.c
Article #3146Re: <varargs.h> vs. function prototypes
From: Tony L. Hansen
Date: Tue, 18 Jun 1991 14:58
Date: Tue, 18 Jun 1991 14:58
34 lines
1384 bytes
1384 bytes
< 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 <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@pegasus.att.com, tony@attmail.com
att!pegasus!hansen, attmail!tony
Technical Details
Message-ID:
<1991Jun18.145823.2512@cbnewsk.att.com>Path:
arc1-ca.pugleaf.net!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!hansenReferences:
<25353@oolong.la.locus.com> <159364@pyramid.pyramid.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <varargs.h> vs. function prototypes Keywords: <varargs.h> 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