Skip to content

Instantly share code, notes, and snippets.

View lbiaggi's full-sized avatar

Lucas Biaggi lbiaggi

  • 18:26 (UTC +01:00)
View GitHub Profile
@lbiaggi
lbiaggi / closure-wrap-function.c
Created July 16, 2021 14:16 — forked from cyfdecyf/closure-wrap-function.c
Examples to wrap function in C in different ways (workable or not)
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
// This code can now only work on Linux system.
// It has some problem on OS X. Maybe I'll fix it someday.
#if __WORDSIZE != 64 || !defined(__x86_64__)
#error "This program only works on IA64 machine."
@lbiaggi
lbiaggi / closures-basic.c
Created July 16, 2021 14:16 — forked from vidarh/closures-basic.c
A number of ways to implement closures in C, in preparation of an upcoming blog post
#include <stdio.h>
#include <stdlib.h>
struct closure {
void (* call)(struct closure *);
int x;
};