Usually you want to use the FFI which will generate this for you.
ast.c is an example shared library written by hand without the FFI.
If you want to copy Scheme variables to globals in C, you should use
sexp_preserve_object to be sure they don't get gc'ed. But in general
this is advanced usage and should be done with caution - sexp_env_define
is safer.
--
Alex