Skip to content

Instantly share code, notes, and snippets.

@XanClic
Created September 11, 2017 15:36
Show Gist options
  • Save XanClic/ed32f562b3335a99b27907cb0d096383 to your computer and use it in GitHub Desktop.
Save XanClic/ed32f562b3335a99b27907cb0d096383 to your computer and use it in GitHub Desktop.
#include <stdint.h>
#include <stdio.h>
#include <callback.h>
static void fn(void *x, va_alist alist)
{
va_start_void(alist);
printf("%i %i\n", (int)(uintptr_t)x, va_arg_int(alist));
va_return_void(alist);
}
int main(void)
{
int (*f)(int) = alloc_callback(fn, 42);
f(23);
return 0;
}
@XanClic
Copy link
Author

XanClic commented Sep 11, 2017

$ gcc callback.c
$ ./a.out
42 23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment