S
skillzero
Is there a portable way to process some of a va_list (with va_arg) in
one function then pass that va_list to another function to process
some of the va_list and then go back to the original function to
process the rest of it?
I've implemented a custom printf that handles the normal format
specifiers, but I'd like an extension mechanism so external code can
add custom format specifiers (e.g. MyPrintF( "%d %{xyz} %s", 123,
arg1, arg2, "string" ) where "xyz" and arg1 and arg2 are handled by an
external function). The problem is that the external code would need
access to the va_list and any va_arg's the external code does would
need to be reflected in the original va_list so that when control
returns to the original function, it can continue to use va_arg for
any remaining arguments. The original va_list is passed to my function
as a parameter (like vprintf) so I can't just put the va_list in a
structure and pass a pointer to the structure around.
Since va_list is implementation defined and may be an array type, I'm
not sure how to do this or if it's even possible in a portable way.
one function then pass that va_list to another function to process
some of the va_list and then go back to the original function to
process the rest of it?
I've implemented a custom printf that handles the normal format
specifiers, but I'd like an extension mechanism so external code can
add custom format specifiers (e.g. MyPrintF( "%d %{xyz} %s", 123,
arg1, arg2, "string" ) where "xyz" and arg1 and arg2 are handled by an
external function). The problem is that the external code would need
access to the va_list and any va_arg's the external code does would
need to be reflected in the original va_list so that when control
returns to the original function, it can continue to use va_arg for
any remaining arguments. The original va_list is passed to my function
as a parameter (like vprintf) so I can't just put the va_list in a
structure and pass a pointer to the structure around.
Since va_list is implementation defined and may be an array type, I'm
not sure how to do this or if it's even possible in a portable way.