Re: parsing variable arg lists via va_list pointers (any gurus here?)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hallvard B Furuseth

    Re: parsing variable arg lists via va_list pointers (any gurus here?)

    Jesse Ziser writes:
    I don't think va_copy() helps with what I'm trying to do,
    unless I'm missing something.
    Well, you could call va_copy() before passing the va_list to foo(),
    which records somewhere the types of the arguments it grabbed. Then the
    caller walks past these args in the original va_list, just discarding
    the args which foo says it has parsed.
    for(;;) switch (*argtypes_eate n_by_foo++) {
    case 's': (void) va_arg(ap, char *); break;
    case 'i': (void) va_arg(ap, int); break;
    ...
    }
    Cumbersome though. However in some cases it simplifies parsing to
    do it in two passes.

    --
    Hallvard
Working...