[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [plt-scheme] mzc: giving C programs functions
At Mon, 10 Jun 2002 19:37:45 -0400, "Mike T. Machenry" wrote:
> 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.
mzc doesn't map Scheme functions to C functions.
To call Scheme from C, you have to get a Scheme function value, perhaps
using scheme_lookup_global(), and then call it with scheme_apply(). The
scheme_apply() function takes an array of Scheme values for the
function's arguments, and it returns a Scheme value for the result.
It doesn't matter whether the Scheme function is compiled by mzc or not.
Of course, you can write a wrapper C function that finds the Scheme
function, marshals the arguments to Scheme values, and calls
scheme_apply(). But, at the moment, we don't have any tools to do that
automatically.
Matthew