Argument Variables

I have a few questions regarding variable numbers of arguments:

  • Why va_start, va_argand are va_enddefined as macros, and not as functions?

  • How does it work va_start? Does it have access to the stack of function calls and bypasses the stack until it finds the last argument specified?

+4
source share
3 answers

The rationale for why they are macros is described in The rationale for international standard programming languages-C in the 7.15Variable Arguments section, he says:

va_start va_arg , va_start , , va_arg , .

C , x86:

typedef char *va_list;
#define va_start( list, param ) (list = (va_list)(&param + sizeof( param )))
#define va_arg( list, type )    (*(type *)((list += sizeof( type )) - sizeof( type ))

++ ++?, , .

+2

va_end , , , va_start ( & , ). va_end va_start , & , .

va_arg , , .

va_start , : , , , .

va_list, ( va_start), , va_arg, .

+1

va_start, va_arg va_end , ( ) .

, , . , . , va_arg , , ( ).

0

All Articles