Next: va_copy
, Previous: utimes
, Up: ISO C and POSIX Function Substitutes [Contents][Index]
va_arg
POSIX specification:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/va_arg.html
Gnulib module: —
Portability problems fixed by Gnulib:
Portability problems not fixed by Gnulib:
va_arg
must be a type that is invariant under
the “default argument promotions” (ISO C 99 6.5.2.2 paragraph 6). This
means that the following are not valid here:
Use ‘double’ instead.
Use ‘int’ instead.
Use ‘int’ or ‘unsigned int’ instead.
This is a portability problem because you don’t know the width of some
abstract types like uid_t
, gid_t
, mode_t
. So, instead of
mode = va_arg (ap, mode_t);
you have to write
mode = (sizeof (mode_t) < sizeof (int) ? va_arg (ap, int) : va_arg (ap, mode_t));