Initial commit

This commit is contained in:
Fabien Freling 2019-05-10 13:45:32 +02:00
parent 6499d7d7ae
commit 18f29579e0
7 changed files with 78 additions and 0 deletions

21
c/main.c Normal file
View file

@ -0,0 +1,21 @@
#include <caml/mlvalues.h>
#include <caml/callback.h>
#include <stdio.h>
void print_closure(const char *closure_name) {
value * closure_f = caml_named_value(closure_name);
if (closure_f == NULL) {
printf("ERROR: Unreachable closure %s\n", closure_name);
return;
}
const char *str = String_val(caml_callback(*closure_f, Val_unit));
printf("%s: %s\n", closure_name, str);
}
int main(int argc, char **argv) {
caml_main(argv);
print_closure("Hello callback");
print_closure("Bye callback");
return 0;
}