A variable argument passing scheme written in C (C11). It's an alternative to stdarg or varargs, but not compatible with either.
Release Version | Release Notes |
---|---|
RELEASENOTES |
There is an API to access mulle-vararg arguments. You can also build up a mulle-vararg manually with the builder functions.
mulle-vararg assumes that the arguments are not layed out in stack alignment fashion but like in a struct. The C promotion rules are still observed though.
Remember the C argument promotion rules are
- char and short to int/unsigned int
- float to double
Let's assume there is a compiler that uses mulle-vararg for variable arguments. It collects all function parameters and packs them into a struct, then passes this struct to the function.
A printf function being being called like this:
printf( "%d %f %lld\n", (char) 'x', (float) 0.2, 1848LL;
would get its arguments embedded in a struct like this
struct
{
char *format;
struct
{
int value1; // standard char -> int promotion
double value2; // standard float -> double promotion
long long value3;
} varargs;
} _param;
mulle-vararg provides the necessary functions to read such a struct. It has some experimental code to write to it.
- Easy to write in C, does not need compiler ABI internals to construct or read. You don't need libffi or some such.
- Cheap forwarding to other functions.
- Not compatible with
<stdarg.h>
This project is a component of the mulle-core library. As such you usually will not add or install it
individually, unless you specifically do not want to link against
mulle-core
.
Use mulle-sde to add mulle-vararg to your project:
mulle-sde add github:mulle-c/mulle-vararg
To only add the sources of mulle-vararg with dependency sources use clib:
clib install --out src/mulle-c mulle-c/mulle-vararg
Add -isystem src/mulle-c
to your CFLAGS
and compile all the sources that were downloaded with your project.
Use mulle-sde to build and install mulle-vararg and all dependencies:
mulle-sde install --prefix /usr/local \
https://github.com/mulle-c/mulle-vararg/archive/latest.tar.gz
Install the requirements:
Requirements | Description |
---|---|
mulle-c11 | 🔀 Cross-platform C compiler glue (and some cpp conveniences) |
Download the latest tar or zip archive and unpack it.
Install mulle-vararg into /usr/local
with cmake:
cmake -B build \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_PREFIX_PATH=/usr/local \
-DCMAKE_BUILD_TYPE=Release &&
cmake --build build --config Release &&
cmake --install build --config Release
Nat! for Mulle kybernetiK