🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #869

Re: Passing a `va_list *'

#869
From: Doug Gwyn
Date: Mon, 30 Oct 1989 14:09
24 lines
1899 bytes
In article <MCGRATH.89Oct28150927@paris.Berkeley.EDU> mcgrath@paris.Berkeley.EDU (Roland McGrath) writes:
>I don't see the problem with whatever type `va_list' is.  You can take the
>address of an object of any type (though not every storage class), and
>dereference the pointer thus obtained.

I'm not sure there is a problem, but you need to check carefully what
happens when va_list is an array type (which is permitted but not
required by the Standard).  I'm away from my copy of the Standard now,
but for example if va_arg() were permitted to be a function, *args in
the inner function would be an attempt to pass an array to va_args(),
not just the name of an array (which would be converted to a pointer
to the array's first element) as in the top-level function.  I forget
whether this usage would also result in conversion to a pointer to
the first element, but if not then it is illegal (and if it did
work, would result in the wrong type being passed to va_args()).  I'll
have to look this up and let you know.

In any case &array will do something different in older PCC implementations
than in Standard C (and is officially not allowed according to K&R1), so if
the code has to work in both <varargs.h> and <stdarg.h> environments, it
may not be portable.

I wish I remembered why we allowed (in one draft, even required) the
va_list to be an array type.  It sure is a nuisance.
Technical Details
Message-ID: <11442@smoke.BRL.MIL>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!uflorida!haven!adm!smoke!gwyn
References: <MCGRATH.89Oct27150426@tully.Berkeley.EDU> <11439@smoke.BRL.MIL> <MCGRATH.89Oct28150927@paris.Berkeley.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!uflorida!haven!adm!smoke!gwyn
From: gwyn@smoke.BRL.MIL (Doug Gwyn)
Newsgroups: comp.std.c
Subject: Re: Passing a `va_list *'
Message-ID: <11442@smoke.BRL.MIL>
Date: 30 Oct 89 14:09:26 GMT
References: <MCGRATH.89Oct27150426@tully.Berkeley.EDU> <11439@smoke.BRL.MIL> <MCGRATH.89Oct28150927@paris.Berkeley.EDU>
Reply-To: gwyn@brl.arpa (Doug Gwyn)
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 24