|
infix
A JIT-Powered FFI Library for C
|
Cookbook Chapter 4: Calling a Function Pointer from a Struct. More...
Classes | |
| struct | Adder |
| struct | AdderVTable_t |
Typedefs | |
| typedef struct AdderVTable_t | AdderVTable |
Functions | |
| static int | vtable_add (Adder *self, int amount) |
| static void | vtable_destroy (Adder *self) |
| static Adder * | create_adder (int base) |
| int | main () |
Variables | |
| const AdderVTable | VTABLE = {vtable_add, vtable_destroy} |
Cookbook Chapter 4: Calling a Function Pointer from a Struct.
This example demonstrates how to call a function pointer that is a member of a struct. This pattern is common in C for emulating object-oriented v-tables or for creating plugin interfaces.
The process is two-step:
infix forward trampoline for that specific function pointer's signature and call it. | typedef struct AdderVTable_t AdderVTable |
|
static |
| int main | ( | void | ) |
|
static |
|
static |
| const AdderVTable VTABLE = {vtable_add, vtable_destroy} |