I was looking for some code about macros, and I found a code like this, for the macro « va_start » :
#define __va_argsiz(t) \
(((sizeof(t) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
#define va_start(ap, pN) \
((ap) = ((va_list) (&pN) + __va_argsiz(pN)))
I would like to know what is the goal of « __va_argsiz » function exactly. Is it alignment limitations ?
Thanks !
Both alignment, and the default type promotion rules in C.
It looks like it is used to compute the start of the variable argument list, based on the size of the first argument. The first argument is the required normal one, i.e. for printf()
it would be the pointer to the formatting string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With