Article View: comp.std.c
Article #3973stdargs: passing (va_list *) to worker routines
From: Paul G. Fox
Date: Tue, 12 Sep 1995 20:07
Date: Tue, 12 Sep 1995 20:07
47 lines
1927 bytes
1927 bytes
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.
the question is this:
must the usage of
foo = va_arg(ap, type_of_foo);
be confined to the same routine in which the
va_list ap;
and
va_start(ap, last_fixed_arg);
expansions occur?
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.
given that my code has ported to most modern and older unix'es, and to
multiple flavors of compiler under DOS, Windows, OS/2, and NT, i'm a little
surprised to suddenly find that my construct may actually not be portable.
anyone have an idea what's going on here?
paul
--
---------------------
paul fox american internet corporation
pgf@american.com (home: pgf@foxharp.boston.ma.us)
"As you can see, unraveling even a small part of 'sendmail'
can introduce more complexity than answers." --Brian Costales, _sendmail_
Technical Details
Message-ID:
<434pa4$c4c@news1.wing.net>Path:
arc1-ca.pugleaf.net!news.wing.net!pgfShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.wing.net!pgf From: pgf@american.com (Paul G. Fox) Newsgroups: comp.std.c Subject: stdargs: passing (va_list *) to worker routines Date: 12 Sep 1995 20:07:32 GMT Organization: Wilder Internet Gateway, Boston, MA Message-ID: <434pa4$c4c@news1.wing.net> NNTP-Posting-Host: longfellow.american.com X-Newsreader: TIN [version 1.2 PL2]