Article View: comp.std.c
Article #860Re: Passing a `va_list *'
From: Doug Gwyn
Date: Sat, 28 Oct 1989 05:56
Date: Sat, 28 Oct 1989 05:56
27 lines
1526 bytes
1526 bytes
In article <MCGRATH.89Oct27150426@tully.Berkeley.EDU> mcgrath@tully.Berkeley.EDU (Roland McGrath) writes:
>#include <stddef.h>
That should be <stdarg.h>, of course.
> va_list args;
> ack(&args);
...
>void ack(va_list *args)
>{
> blip(va_arg(args, int **));
>}
I wonder how this could possibly have worked. va_arg() takes a va_list
as its first argument, not a va_list*. Let's assume this is a typo.
I don't have my copy of the Standard at hand at the moment, but I did
spend a lot of time working in this area, and as I recall the Standard
guarantees that you can pass the va_list to a function and continue to
use it within the function, but not necessarily a pointer to the va_list.
Upon return from the function, the va_list is "dead" until va_end()ed
and re-va_start()ed.
To answer the question of whether you can use a pointer to the va_list,
you need to consider what types are allowed for va_list. I don't recall
exactly how this ended up; it changed around a few times. The one to
watch out for is an array type.
Technical Details
Message-ID:
<11439@smoke.BRL.MIL>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwynReferences:
<MCGRATH.89Oct27150426@tully.Berkeley.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: Passing a `va_list *' Message-ID: <11439@smoke.BRL.MIL> Date: 28 Oct 89 05:56:13 GMT References: <MCGRATH.89Oct27150426@tully.Berkeley.EDU> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 27