[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Re: Calling Chicken from C/C++
From: |
felix winkelmann |
Subject: |
Re: [Chicken-users] Re: Calling Chicken from C/C++ |
Date: |
Thu, 9 Dec 2004 07:38:57 +0100 |
On Wed, 8 Dec 2004 23:29:48 +0000, Joel Reymont <address@hidden> wrote:
> I take the question back! It's all in the Chicken manual under Interface
> to External Functions -> Entry points. Darn, so easy :-(. Thank you guys!
>
You're welcome! :-)
I recommend using define-embedded, it's probably the most
straightforward method:
$ cat x.scm
(include "chicken-default-entry-points")
(define c 1)
(define-embedded (scheme (c-string x)) c-string
(print x ": " c)
(set! c (add1 c))
(number->string c) )
$ cat y.c
#include <stdio.h>
extern int scheme(char *str);
int main()
{
int i;
for(i = 0; i < 10; ++i)
printf("C: %s\n", scheme("yo!"));
return 0;
}
$ csc x.scm -ekvc -debug 2 && gcc y.c `chicken-config -libs` x.o -o y && ./y
cheers,
felix