infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
Ch04_CallbackAsArg.c File Reference

Cookbook Chapter 4: Receiving and Calling a Function Pointer. More...

#include <infix/infix.h>
#include <stdio.h>
Include dependency graph for Ch04_CallbackAsArg.c:

Functions

static int multiply_handler (int x)
 
static int harness_func (int(*worker_func)(int), int base_val)
 
int main ()
 

Detailed Description

Cookbook Chapter 4: Receiving and Calling a Function Pointer.

This example demonstrates a powerful composition of forward and reverse calls. We create a reverse trampoline (a callback) and then pass its function pointer as an argument to another C function using a forward trampoline.

This pattern is very common in C APIs that use callbacks for event handling, sorting, or iteration.

Function Documentation

◆ harness_func()

static int harness_func ( int(*)(int)  worker_func,
int  base_val 
)
static

◆ main()

int main ( void  )

◆ multiply_handler()

static int multiply_handler ( int  x)
static