[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] help on embedding
From: |
Thomas Christian Chust |
Subject: |
Re: [Chicken-users] help on embedding |
Date: |
Sun, 23 Sep 2007 17:20:25 +0200 |
User-agent: |
Thunderbird 2.0.0.6 (Macintosh/20070728) |
Todd Ingalls wrote:
> [...] I can generate the c file just fine (> chicken
> chicken-bridge.scm -output-file chicken-bridge.cpp -quiet -no-trace
> -optimize-level 2 .......) and then when compiling the larger c
> executable I pass DC_EMBEDDED and everything compiles and links just
> fine. However, the new procedures I have define are not available. I am
> sure I am missing some simple step here , could anyone help me out on
> how to do this? [...]
Hello,
maybe you forgot to run the function representing the top level of your
scheme code. Something like this should work:
% cat unit-say-hello.scm
(declare
(unit say-hello)
(export say-hello))
(define (say-hello)
(print "Hello world!"))
(return-to-host)
% cat host-say-hello.c
#include <chicken.h>
extern void C_ccall C_say_hello_toplevel(C_word c, C_word self, C_word
k) C_noret;
int main(int nargs, char **args) {
int heap, stack, symbols;
CHICKEN_parse_command_line(nargs, args, &heap, &stack, &symbols);
CHICKEN_initialize(heap, stack, symbols, (void *)C_say_hello_toplevel);
CHICKEN_run(NULL);
return CHICKEN_eval_string("(say-hello)", NULL);
}
% csc -embedded -c unit-say-hello.scm
% csc -c host-say-hello.c
% csc unit-say-hello.o host-say-hello.o -o say-hello
% ./say-hello
Hello world!