Article View: comp.unix.programmer
Article #3510Re: Variable length arg lists in C (gcc): stdarg vs. varargs
From: Barry Margolin
Date: Thu, 12 Oct 2000 00:00
Date: Thu, 12 Oct 2000 00:00
36 lines
2704 bytes
2704 bytes
In article <8s2tvu$duk$1@yin.interaccess.com>, Kenny McCormack <gazelle@interaccess.com> wrote: >In article <xm2F5.47$xe3.691@burlma1-snr2>, >Barry Margolin <barmar@genuity.net> wrote: >... >>Basically, K&R C had varargs. The standardization committee designed >>stdargs as the replacement for it. The main difference has to do with the >>fact that stdargs is designed to coexist with function prototypes, i.e. the >>funcname(<fixed args>,...) notation. > >I can't quite parse your meaning here. Are you saying that varargs did not >have the "at least one fixed arg" requirement? If so, then that's what I >meant in the original post when I stated that it was my understanding that >varargs was more powerful (I.e., more powerful b/c it did not have this >requirement/limitation) Yes, varargs didn't have that requirement. However, since it didn't automatically pass the number of arguments, you still had to have at least one argument, either an initial argument that was used to determine how many variable arguments there are (like the format string in printf, or the count I suggested for your max() function) or a last argument with a distinguished value. >>I don't think there's a vscanf(), though (it's not on my Solaris 2.6 >>system). > >Present on Linux, but not on Solaris (AFAICT). So it's probably not required by ISO C or POSIX (unless it's a recent addition that hasn't made it into Solaris yet). -- Barry Margolin, barmar@genuity.net Genuity, Burlington, MA *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups. Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Technical Details
Message-ID:
<yymF5.14$OD4.185@burlma1-snr2>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<8s26b3$9vl$1@yin.interaccess.com> <8s2apd$aqe$1@yin.interaccess.com> <xm2F5.47$xe3.691@burlma1-snr2> <8s2tvu$duk$1@yin.interaccess.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc89c,22450a31b48667a4 X-Google-Attributes: gidfc89c,public X-Google-Thread: f65d0,22450a31b48667a4 X-Google-Attributes: gidf65d0,public From: Barry Margolin <barmar@genuity.net> Subject: Re: Variable length arg lists in C (gcc): stdarg vs. varargs Date: 2000/10/12 Message-ID: <yymF5.14$OD4.185@burlma1-snr2> X-Deja-AN: 680656513 Distribution: world References: <8s26b3$9vl$1@yin.interaccess.com> <8s2apd$aqe$1@yin.interaccess.com> <xm2F5.47$xe3.691@burlma1-snr2> <8s2tvu$duk$1@yin.interaccess.com> X-Abuse-Info: Otherwise we will be unable to process your complaint properly X-Complaints-To: abuse@gtei.net X-Trace: /bCCZHp1MPDL09Ab9NvjXQ6oQTZEGMTMUDVa1sKD40pp3y740FgL1JRxHHPpRmM1ohDNHAazdfmp!pHZ9g1FTmAtcsBZK8UcFMkTA1Utq1v01CqBX89Y9z3Bi7mmYR5rslF1E+w== Organization: Genuity, Cambridge, MA X-Copies-To: never NNTP-Posting-Date: Thu, 12 Oct 2000 17:30:06 GMT Newsgroups: comp.unix.programmer,gnu.gcc Originator: barmar@genuity.net (Barry Margolin)