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

Cookbook Chapter 3: Creating a Type-Safe Callback for qsort. More...

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

Functions

static int compare_integers_handler (const void *a, const void *b)
int main ()

Detailed Description

Cookbook Chapter 3: Creating a Type-Safe Callback for qsort.

This example demonstrates a "reverse call" or callback. We generate a native C function pointer that can be passed to a C library function that expects one. Here, we use infix_reverse_create_callback to create a comparison function for the standard library's qsort.

The key feature of this API is that the handler function (compare_integers_handler) has a clean, type-safe C signature that exactly matches what qsort expects.

Function Documentation

◆ compare_integers_handler()

int compare_integers_handler ( const void * a,
const void * b )
static

◆ main()

int main ( void )