[plt-scheme] scheme_primitive_module
I'd like to access a foreign function within a scheme module, so here's the
attempt (using mzscheme v300):
------------------------------
#include "scheme.h"
#include <stdio.h>
Scheme_Object * func(int argc, Scheme_Object **args){
printf("called func");
return scheme_void;
}
int main(int argc, char ** args)
{
Scheme_Env * env = scheme_basic_env();
// add func to a new module "foreign":
Scheme_Env * mod = scheme_primitive_module(scheme_intern_symbol("foreign"), env);
scheme_add_global("func",
scheme_make_prim_w_arity(func, "func", 0, 0), mod);
scheme_finish_primitive_module(mod);
// test:
char buf[] = "(module test mzscheme "
"(require foreign)"
"(func)"
")"
"(require test)";
scheme_eval_string(buf, env);
return 0;
}
------------------------------
Everything compiles and runs, but "func" never gets called. Am I on the right
track?
Wayne