On Fri, 19 May 2006 18:41:07 GMT, Rick Anderson
<Ri**************@oracle.com> 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