🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #902

Re: varargs vs. stdargs

#902
From: Doug Gwyn
Date: Tue, 14 Nov 1989 14:36
19 lines
1335 bytes
In article <GNB.89Nov14103800@baby.bby.oz> gnb@bby.oz (Gregory N. Bond) writes:
>Is there some method of specifying varadic functions that is portable
>to both old (varargs) and new (stdargs) implementations?

The simple answer is that at some level you have to switch on __STDC__.

>Is there an ANSI prototype for old varargs functions?

No, such functions were not legal C although they happened to work in
most implementations.  Because of the widespread use of printf() in
applications, it behooved implementors to figure out some solution.

>Or do I have two prototyes and two implementations surrounded by
>#if __STDC__?

Some people use macros to make this a bit less painful, but in any
event in the definition of the body of a variadic function you have
to pick up the "fixed" arguments via va_arg() for varargs, but
they're already accessible under stdarg.
Technical Details
Message-ID: <11594@smoke.BRL.MIL>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!brutus.cs.uiuc.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn
References: <GNB.89Nov14103800@baby.bby.oz>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!brutus.cs.uiuc.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn
From: gwyn@smoke.BRL.MIL (Doug Gwyn)
Newsgroups: comp.std.c
Subject: Re: varargs vs. stdargs
Message-ID: <11594@smoke.BRL.MIL>
Date: 14 Nov 89 14:36:27 GMT
References: <GNB.89Nov14103800@baby.bby.oz>
Reply-To: gwyn@brl.arpa (Doug Gwyn)
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 19