Hello, I think I found what went wrong.
Two things that weren't clear to me are: - The right way to create Scheme code callable from C is, first call CHICKEN_run (or CHICKEN_initialize). *And* the Scheme file needs to call "return-to-host" so the definitions there are actually used (is this correct?) - define-external cannot be used for recursive definitions (probably supposed to be used only for wrappers -- is this correct?) My recursive define-external functions segfaulted; non-recursive ones didn't. Did I get this right? Thanks, J. On Mon, Oct 26, 2009 at 01:58:52PM -0200, Jeronimo Pellegrini wrote: > Hi, > > So -- I uninstalled my previous Chicken SVN version and installed 4.2.0; > the problem still happens: > > I was trying to compile the example in > http://chicken.wiki.br/man/4/Embedding > > (The example right below CHICKEN_yield) > > So, I copied and pasted x.scm and y.c, and > used the same command line: > > $ csc x.scm y.c -embedded > > Then tried to run it: > > $ ./x > data: 55d5ba68 > Segmentation fault > > > This example also segfaulted: > > a.c: > > /----------- > #include <chicken.h> > #include <stdio.h> > > extern threetimes (int); > > int main() { > printf("See: %d\n", threetimes(2)); > } > \----------- > > a.scm: > > /----------- > (define-external (threetimes (int n)) int > (* n n n)) > \----------- > > $ csc a.scm a.c -embedded -d2 > > $./a > Segmentation fault > > So... How do I debug those? I tried running the binary in gdb, > but the only thing it told me was that the segfault was in > the function "threetimes"; > > Is there something else I should have done? (I think I understood > what was in the Wiki, but I could be wrong) > > Thanks, > J. > > > > _______________________________________________ > Chicken-users mailing list > [email protected] > http://lists.nongnu.org/mailman/listinfo/chicken-users _______________________________________________ Chicken-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/chicken-users
