unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Re: Calling a scheme procedure from C
       [not found] <E19avXM-0000WB-8w@monty-python.gnu.org>
@ 2003-07-11 16:20 ` Mike Gran
  0 siblings, 0 replies; only message in thread
From: Mike Gran @ 2003-07-11 16:20 UTC (permalink / raw)


When you look up a Scheme function using scm_c_lookup, it doesn't return
the procedure.  It returns the variable that contains the procedure.  To 
then get the procedure, you have to dereference the variable using 
scm_variable_ref.

I would call the function this way...

int main (int argc, char *argv[])
{
    SCM func_symbol;
    SCM func;
   
    scm_init_guile();
   
    func_symbol = scm_c_lookup("write");
    func = scm_variable_ref(func_symbol);
   
    scm_call_1 (func, scm_int2num(10));

    exit(EXIT_SUCCESS);
}





_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-07-11 16:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <E19avXM-0000WB-8w@monty-python.gnu.org>
2003-07-11 16:20 ` Calling a scheme procedure from C Mike Gran

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).