This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Constructing/modifying a va_list


I apologize in advance if this is the wrong forum for this question.

I am trying to figure out how to modify the contents of a va_list inside a
variadic function before I pass that va_list on to vsprintf.  More
specifically, I know that one or more of the parameters passed to the
variadic function are char*'s (and I know which ones they are).  I'd like to
extract those values from the variable argument list, modify the values and
put them back into the variable argument list.  Once that is complete, I'd
like to pass the va_list to vsprintf.

Frustratingly enough, I managed to make this work in MSVC++ because
Microsoft's va_arg() macro evaluates to the location within the argument
list.  The following statements:
	char **tmp_char = &va_arg(ap, char *);
	*tmp_char = new_or_modified_value;
work just fine.  Essentially, doing this is just like assigning a new value
to a formally declared parameter.  Under GCC/GLIBC, however, the expression
"&va_arg()" gives an error because (according to the man and info pages)
va_arg() evaluates to a _copy_ of the value, not the location within the
argument list.

As far as I can tell, the va_list type provided by GCC/GLIBC is opaque and
read-only.  Is there any way to modify its contents or create a new one?
I'm using Redhat Linux 7.1, gcc 2.96 and glibc 2.2.2 but I will gladly
upgrade to a newer version if it would help.

Any suggestions or pointers will be greatly appreciated!

-- Sam Clippinger
   lookandfeel new media

"I know you think you thought you knew what you thought I said, but I'm not
sure you understood what you thought I meant."  - from the net 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]