Article View: comp.std.c
Article #14stdarg facility, va_start more than once?
From: Michael Keirnan aka Joe Cool
Date: Tue, 27 Oct 1992 23:52
Date: Tue, 27 Oct 1992 23:52
37 lines
1957 bytes
1957 bytes
Is using the macro va_start more than once in a function legal in
ANSI C? I was thinking of something along the lines of:
#include <stdarg.h>
void two_pass_arg_eater(int first_arg, ...)
{
va_list ap;
va_start(ap, first_arg);
/* while ... va_arg(ap, type) ... process args pass 1 */
va_end(ap);
va_start(ap, first_arg);
/* while ... va_arg(ap, type) ... process args pass 2 */
va_end(ap);
}
My trusty Harbison and Steele (3rd ed.) does not forbid it as far as I
can tell, but I'm looking for a more authoritative answer. I have not
tried it on any compilers, because a particular compiler's behavior is
not what I seek.
As I am sure I will hear about it anyway <g>, comments concerning the
advisability of this are also welcome, but are perhaps more appropriately
e-mailed to me directly, depending on their relevance to the group.
--
===========================================================================
Michael Keirnan | Internet: mgk@sybase.com
Sr. Software Engineer | Voice: 617-238-6210
Sybase, Inc. | #include <legal/disclaimer.h>
---------------------------------------------------------------------------
There are two kinds of people in the world: those who think there are two
kinds of people in the world and those who are smart enough to know better.
- Tom Robbins
===========================================================================
Technical Details
Message-ID:
<MGK.92Oct27155222@cedar.sql.sybase.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!darwin.sura.net!jvnc.net!yale.edu!nigel.msen.com!sdd.hp.com!hplabs!ucbvax!mtxinu!sybase!mgkShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!darwin.sura.net!jvnc.net!yale.edu!nigel.msen.com!sdd.hp.com!hplabs!ucbvax!mtxinu!sybase!mgk From: mgk@sql.sybase.com (Michael Keirnan aka Joe Cool) Newsgroups: comp.std.c Subject: stdarg facility, va_start more than once? Message-ID: <MGK.92Oct27155222@cedar.sql.sybase.com> Date: 27 Oct 92 23:52:22 GMT Sender: news@Sybase.COM Distribution: comp Organization: Sybase Lines: 37