chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] help on embedding


From: Todd Ingalls
Subject: Re: [Chicken-users] help on embedding
Date: Sun, 23 Sep 2007 10:05:07 -0700

Yes, Thank you so much that is exactly what I was overlooking.



On Sep 23, 2007, at 8:20 AM, Thomas Christian Chust wrote:

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!





reply via email to

[Prev in Thread] Current Thread [Next in Thread]