Writing Native C Extensions

Extend Djazair with high-performance C libraries using djazair_api.h.

Writing a Native C Module

c
#include "djazair_api.h"

// Define native function: adds two numbers in C
DJAZAIR_FUNC(native_fast_add) {
    djazair_check_args(2);
    double a = djazair_get_num(args, 0);
    double b = djazair_get_num(args, 1);
    return djazair_num(a + b);
}

// Register module exports
DJAZAIR_EXTENSION(fastmath, {
    {"fastAdd", native_fast_add, 2},
    {NULL, NULL, 0}
});

You can then compile this file to a shared library (fastmath.dll or fastmath.so) and load it seamlessly in Djazair!