Suppose I have a function which takes variadic arguments (...
) or a va_list
passed from another such function. The main logic is in this function itself (let's call it f1
), but I want to have it pass the va_list
to another function (let's call it f2
) which will determine the next argument type, obtain it using va_arg
, and properly convert and store it for the caller to use.
Is it sufficient to pass a va_list to f2
, or is it necessary to pass a pointer to va_list. Unless va_list is required to be an array type or else store its position data at the location the va_list
object points to (rather than in the object itself), I can't see how passing it by value could allow the calling function (f1
) to 'see' the changes the called function made by va_arg
.
Can anyone shed light on this? I'm interested in what the standard requires, not what some particular implementation allows.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…