If each invocation of va_arg modifies the object declared with va_list so that the object points to the next argument in the list, is there any way to step back so that it points to the previous one, jump back to the first one, jump to the end? Go three quarters of the way though the list and then… you get the idea. Or is it a once passed it’s gone type thing?
If each invocation of va_arg modifies the object declared with va_list so that the
Share
You can “jump back” to the beginning by executing
va_startagain. There is no other supported operation other than going on to the next argument.However, most implementations use trivial pointer arithmetic. If you guarantee the code runs only on a particular architecture, then you can do the reverse of the arithmetic. But this completely defeats the purpose of
va_listwhich is to safely abstract the operations for all architectures.