|
CX Framework
Cross-platform C utility framework
|
Macros | |
| #define | stvarInit(typen, val) { .data = { .st_##typen = val }, .type = stType(typen) } |
| #define | stvar(typen, val) ((stvar) { .data = stArg(typen, val), .type = stType(typen) }) |
| #define | stvNone ((stvar) { .type = stType(none) }) |
Macros for creating and initializing variant containers.
stvar stvar(type, value)
Create a temporary variant containing a typed value.
Uses C99 compound literals to create a stack-allocated temporary with automatic storage duration. The temporary is valid until the end of the enclosing block scope. This is the primary mechanism for passing typed arguments to variadic functions.
IMPORTANT: The variant's lifetime is limited to the current function scope. Do not return these from functions or store pointers to them beyond the current scope.
| typen | Type name (e.g., int32, string, object) |
| val | Value of the specified type |
Example:
| #define stvarInit | ( | typen, | |
| val | |||
| ) | { .data = { .st_##typen = val }, .type = stType(typen) } |
stvar stvarInit(type, value)
Static initializer for variant structures (C only).
Creates a compile-time initializer suitable for static/automatic variable initialization. This is primarily used when declaring persistent variant variables, not for temporary expressions.
| typen | Type name (e.g., int32, string) |
| val | Value of the specified type |
Example:
stvar stvNone
Empty variant constant representing no value.
Used to represent the absence of a value or as a sentinel/terminator in variant arrays. The type field is set to stType(none).
Example: