Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

exec(2)

printf(3S)

vprintf(3S)

stdarg(5)

STDARG(3C)                           SysV                           STDARG(3C)



NAME
     stdarg: va_start, va_arg, va_end - variable arguments

SYNOPSIS
     #include <stdarg.h>

     void va_start(ap, parmN);
     type va_arg(ap, type);
     void va_end(ap);
     va_list ap;

DESCRIPTION
     This set of macros allows you to write functions that accept argument
     lists whose number and types are not known to the function when it is
     translated.  Routines in this category (such as printf(3S)) that don't
     use these macros are inherently nonportable, as different machines use
     different argument-passing conventions.

     va_list is a type defined for the variable used to traverse the
     unspecified argument list.

     va_start initializes ap for subsequent use by va_arg and va_end.  parmN
     is the identifier of the parameter just before the first unspecified
     argument (the one just before the , ...).

     va_arg returns the next argument in the list pointed to by ap.  type is
     the type the argument is expected to be.  Different types can be mixed,
     but is is up to the routine to know what type of argument is expected, as
     it cannot be determined at runtime.

     va_end is used to clean up.

     Multiple traversals, each initiated by va_start and terminated by va_end,
     are possible.

SEE ALSO
     exec(2), printf(3S), vprintf(3S), stdarg(5).

NOTES
     It is up to the calling routine to specify how many arguments there are,
     since it is not always possible to determine this from the stack frame.
     For example, execl is passed a zero pointer to signal the end of the
     list.  printf can tell how many arguments are there by the format.

     You must specify a type to va_arg such that type * returns the type of a
     pointer to an object of the specified type.

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026