🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3983

Re: stdargs: passing (va_list *) to worker routines

#3983
From: Stephen Baynes
Date: Wed, 13 Sep 1995 07:37
34 lines
1938 bytes
Paul G. Fox (pgf@american.com) wrote:
: hi -- i recently hit a portability problem involving code written
: using stdarg.h, and i'm wondering if it's me or the vendor that's
: at fault.
-snip-
: or, can i pass "&ap" to a lower level routine where it's
: declared like this:
: 	va_list *app
: and used as:
: 	bar = va_arg(*app, type_of_bar)

: the code i have does the latter, i.e. it passes a pointer to "ap" to
: the lower level routine.  [the reason is that the top routine which is
: actually called with variable arguments farms out work to lower level
: routines, but they want to do their work on the original variable list.]

: this particular vendor's stdarg.h, however, contains:
: 	typedef char   *va_list[1];
: instead of the more typical
: 	typedef char   *va_list;

: the vendor's introduction of array semantics causes my "&ap" to break.

I think it should work, even though the vendor has used an array for va_list
because in ANSI C one can have pointers to arrays which work just like
any other pointers. Check that the compilers handling of pointers to arrays
is not broken. There should be no problem in using a va_list in a function
called from the one it was set up in - vprintf for example relies on this.

--
Stephen Baynes                              baynes@mulsoc2.serigate.philips.nl
Philips Semiconductors Ltd
Southampton                                 My views are my own.
United Kingdom
Technical Details
Message-ID: <DEu2I0.KIJ@ukpsshp1.serigate.philips.nl>
Path: arc1-ca.pugleaf.net!phcoms4.seri.philips.nl!panther!baynes
References: <434pa4$c4c@news1.wing.net>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!phcoms4.seri.philips.nl!panther!baynes
From: baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes)
Subject: Re: stdargs:  passing (va_list *) to worker routines
Sender: news@ukpsshp1.serigate.philips.nl (account for localnews)
Message-ID: <DEu2I0.KIJ@ukpsshp1.serigate.philips.nl>
Date: Wed, 13 Sep 1995 07:37:12 GMT
References: <434pa4$c4c@news1.wing.net>
Organization: Philips Semiconductors, Southampton, UK
X-Newsreader: TIN [version 1.2 PL2]