plibsys 0.0.5
|
Variable arguments. More...
Go to the source code of this file.
Macros | |
#define | p_va_list va_list |
Opaque type holding variable number of arguments navigation. | |
#define | p_va_start(ap, last) |
Initializes navigation through a variable number of arguments. | |
#define | p_va_arg(ap, type) |
Gets the next argument in the list. | |
#define | p_va_end(ap) |
Ends the navigation. | |
#define | p_va_copy(dst, src) |
Copies a navigation object. | |
#define | pint8_va_arg(ap) |
Unstacks a pint8 variable. | |
#define | puint8_va_arg(ap) |
Unstacks a puint8 variable. | |
#define | pint16_va_arg(ap) |
Unstacks a pint16 variable. | |
#define | puint16_va_arg(ap) |
Unstacks a puint16 variable. | |
#define | pint32_va_arg(ap) |
Unstacks a pint32 variable. | |
#define | puint32_va_arg(ap) |
Unstacks a puint32 variable. | |
#define | pint64_va_arg(ap) |
Unstacks a pint64 variable. | |
#define | puint64_va_arg(ap) |
Unstacks a puint64 variable. | |
#define | ppointer_va_arg(ap) |
Unstacks a ppointer variable. | |
#define | pconstpointer_va_arg(ap) |
Unstacks a pconstpointer variable. | |
#define | pboolean_va_arg(ap) |
Unstacks a pboolean variable. | |
#define | pchar_va_arg(ap) |
Unstacks a pchar variable. | |
#define | pshort_va_arg(ap) |
Unstacks a pshort variable. | |
#define | pint_va_arg(ap) |
Unstacks a pint variable. | |
#define | plong_va_arg(ap) |
Unstacks a plong variable. | |
#define | puchar_va_arg(ap) |
Unstacks a puchar variable. | |
#define | pushort_va_arg(ap) |
Unstacks a pushort variable. | |
#define | puint_va_arg(ap) |
Unstacks a puint variable. | |
#define | pulong_va_arg(ap) |
Unstacks a pulong variable. | |
#define | pfloat_va_arg(ap) |
Unstacks a pfloat variable. | |
#define | pdouble_va_arg(ap) |
Unstacks a pdouble variable. | |
Variable arguments.
Functions declared with a variable number of arguments use macros to step through them.
The p_va_list type must be declared in such function, p_va_start, p_va_arg and p_va_end are used to initialize, to step through and to end the navigation, respectively.
A variable number of arguments can be propagated to another function which accepts a p_va_list parameter, using p_va_copy.
Any use of p_va_start or p_va_copy must have a corresponding p_va_end.
Using a variable number of parameters requires a known-in-advance contract between the caller and the callee on the number of parameters and their types. Note, that this mechanism is a weakly typed: the compiler will always apply default type promotion, regardless if you explicitely typecast an argument in the stack, i.e.:
You need to be very careful when using variable arguments. Improper usage may lead to program crash. In order to avoid type casting mistakes, consider using macros for variable arguments with explicit type casting provided below. Though you still can use p_va_arg if you know what are you doing.
Please note, that stdarg.h implementation is not compatible with varargs.h, and only one of them should be used in a compilation unit. You must be sure that you don't use varargs.h along with the current implmenetation, otherwise runtime failures are inevitable.
Definition in file pstdarg.h.
#define p_va_arg | ( | ap, | |
type ) |
Gets the next argument in the list.
ap | Declared object of type va_list, previously initalized with p_va_start. |
type | Type of the next argument. |
#define p_va_copy | ( | dst, | |
src ) |
Copies a navigation object.
#define p_va_end | ( | ap | ) |
Ends the navigation.
ap | Declared object of type p_va_list. |
#define p_va_list va_list |
#define p_va_start | ( | ap, | |
last ) |
Initializes navigation through a variable number of arguments.
ap | Declared object of type p_va_list. |
last | Name of the last argument before ap. |
#define pboolean_va_arg | ( | ap | ) |
#define pchar_va_arg | ( | ap | ) |
#define pconstpointer_va_arg | ( | ap | ) |
Unstacks a pconstpointer variable.
ap | p_va_list stack. |
#define pdouble_va_arg | ( | ap | ) |
#define pfloat_va_arg | ( | ap | ) |
#define pint16_va_arg | ( | ap | ) |
#define pint32_va_arg | ( | ap | ) |
#define pint64_va_arg | ( | ap | ) |
#define pint8_va_arg | ( | ap | ) |
#define pint_va_arg | ( | ap | ) |
#define plong_va_arg | ( | ap | ) |
#define ppointer_va_arg | ( | ap | ) |
#define pshort_va_arg | ( | ap | ) |
#define puchar_va_arg | ( | ap | ) |
#define puint16_va_arg | ( | ap | ) |
#define puint32_va_arg | ( | ap | ) |
#define puint64_va_arg | ( | ap | ) |
#define puint8_va_arg | ( | ap | ) |
#define puint_va_arg | ( | ap | ) |
#define pulong_va_arg | ( | ap | ) |