[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[plt-scheme] mzc: giving C programs functions



hello,
  i am having problems using mzc. i am trying to create a .o file
which i will link with C code and access the function from C. i
looked into c-lambda and c-declare but they seem to allow me to
embed C into the scheme code, not the other way around. what i
want is a simple module.

(module foo mzscheme
  (require (lib "xml.ss" "xml"))
  (provide myfunc)
  (define myfunc
    (lambda (n)
      (write-xml/content
        ...))))

then i run
mzc foo.ss

then i write
int main (char *argv[], int argc) {
  myfunc ("foo");
  return 0;
}
and run
gcc -Lfoo.so cprog.c

but this gives me undeclared identifier for myfunc. i was pretty sure this
would not work as myfunc does not even specify it's parameter's type.

i then tried to convert my function to C and then compile it with GCC but
reading through the machine generated C code gave me no clues as to which
function to call inorder to get the results of myfunc. does anyone know
how i can write C functions in scheme?
thanks
-mike