How to remove this warning: second parameter of ‘va_start’ not last named argument?

You need to use size instead of fmt:

va_start(args, size);

It is size, not fmt, that is the last parameter that has an explicit name (as opposed to vararg parameters, which have no names). You need to pass the last named parameter to va_start in order for it to figure out the address in memory at which the vararg parameters start.


second parameter of ‘va_start’ not last named argument

What does it means and how to remove it?

Your function has named parameters parent, fmt and size. The C spec says you have to always pass the last named parameter to va_start, for compatibility with older compilers. So you must pass size, not fmt.

(But with a modern compiler, it might work anyway)


I think there is a confusion here: most of people only deal with prinf-like functionsh which have format and varargs. and they think they have to pass parameter name which describes format. however va_start has nothing to do with any kind of printf like format. this is just a function which calculates offset on the stack where unnamed parameters start.

Tags:

Linux

C

Gcc