Article View: comp.std.c
Article #3980Re: stdargs: passing (va_list *) to worker routines
From: Tanmoy Bhattacharya
Date: Wed, 13 Sep 1995 02:50
Date: Wed, 13 Sep 1995 02:50
56 lines
2511 bytes
2511 bytes
In article <434pa4$c4c@news1.wing.net>, pgf@american.com (Paul G. Fox) writes: <snip> |> 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? No. The standard explicitly says you can pass "ap" to a function. |> |> 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 standard does not mention passing &ap. But it says you _can_ pass ap (but if you call va_arg on that, the original ap, i.e. the ap in the original function becomes unusable till a va_end). I believe in the absence of explicit statement, your use should be allowed, and the original ap should still be usable. |> |> 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 do not understand this. In what context does a fully paranthesized expression `(*&a)' differ from `a' if `a' is an addressable lvalue? I believe this set of parantheses in the definition of va_arg is mandatory. Cheers Tanmoy -- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242) Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87544-0285,USA H:#3,802,9 St,NM87545 Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>, <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/ internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html> fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
Technical Details
Message-ID:
<435gt4$jgj@newshost.lanl.gov>Path:
arc1-ca.pugleaf.net!qcd.lanl.gov!tanmoyReferences:
<434pa4$c4c@news1.wing.net>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!qcd.lanl.gov!tanmoy From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) Newsgroups: comp.std.c Subject: Re: stdargs: passing (va_list *) to worker routines Date: 13 Sep 1995 02:50:12 GMT Organization: Los Alamos National Laboratory Distribution: world Message-ID: <435gt4$jgj@newshost.lanl.gov> References: <434pa4$c4c@news1.wing.net> NNTP-Posting-Host: qcd.lanl.gov