Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > varargs question: va_list in structure

Reply
Thread Tools

varargs question: va_list in structure

 
 
Rick Anderson
Guest
Posts: n/a
 
      05-19-2006
I want to store a "va_list" in a structure (which gets passed around
from function to function). I cannot use the va_copy() routine
to create a copy of the varargs (it looks like it uses stack memory).

Has anyone written some portable code to create a copy of the varargs
information, and subsequent routines to retrieve the varargs information?

Thanks in advance!
Rick
 
Reply With Quote
 
 
 
 
Richard Bos
Guest
Posts: n/a
 
      05-22-2006
Rick Anderson <> wrote:

> I want to store a "va_list" in a structure (which gets passed around
> from function to function). I cannot use the va_copy() routine
> to create a copy of the varargs (it looks like it uses stack memory).
>
> Has anyone written some portable code to create a copy of the varargs
> information,


Yes; it's called va_copy().

Otherwise, the contents of a va_list are entirely system-dependent. The
Standard says nothing about its layout; all it specifies is how one may
be used.

Richard
 
Reply With Quote
 
 
 
 
Dave Thompson
Guest
Posts: n/a
 
      05-29-2006
On Fri, 19 May 2006 18:41:07 GMT, Rick Anderson
<> wrote:

> I want to store a "va_list" in a structure (which gets passed around
> from function to function). I cannot use the va_copy() routine
> to create a copy of the varargs (it looks like it uses stack memory).
>

What do you mean 'looks like'? Do you just mean the syntax looks like
a function call? It needn't be, and IME never is. Each of the
va_list's will certainly occupy space, but if you want to have them
there's no way around that.

> Has anyone written some portable code to create a copy of the varargs
> information, and subsequent routines to retrieve the varargs information?
>

va_list is permitted to be location dependent in an unspecified
fashion = dependent on the implementation and undocumented, so no one
could possibly write fully Standard code to do this. That's why
va_copy exists.

On all implementations I know of either a bitwise copy with memcpy
(for array) or an assignment (otherwise) works. But any implementation
where va_copy is provided and does something which is less efficient
than (whichever of) those, is so badly done I wouldn't trust it for
int main ( void ) { return 0; }

Or, do you actually need to copy? Can you just va_start the one in
your structure to start with?

- David.Thompson1 at worldnet.att.net
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why can't you use varargs and keyword arguments together? Sandra-24 Python 1 12-22-2006 01:03 AM
Converting a varargs tuple to a list - a definite pitfall for new comers to Python metaperl.etc@gmail.com Python 5 09-15-2006 10:38 AM
ArrayList to Varargs =?iso-8859-1?B?bW9vcJk=?= Java 1 12-12-2005 01:48 PM
Varargs Chris Uppal Java 4 01-20-2005 09:10 AM
passing varargs to another function Ian Partridge C Programming 2 12-24-2003 02:38 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57