#include #include #include 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; }