[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Implementing a C-API to a chicken library
From: |
Thomas Chust |
Subject: |
Re: [Chicken-users] Implementing a C-API to a chicken library |
Date: |
Fri, 09 May 2014 17:45:55 +0200 |
On Fri, 2014-05-09 at 16:56 +0200, Isak Andersson wrote:
> [...]
> Basically I want to define a C API (because that's easy to call from
> all languages) that will be used on many platforms
> (ios, android, winrt, windows, osx etc).
> [...]
Hello Isak,
what you want to do should indeed be possible to achieve using
define-external. However, CHICKEN's runtime system needs to be
initialized and the top-level Scheme code needs to be run before you can
call back into scheme.
> [...]
> So what I did was that I created a simple test with the following
> source code:
> https://gist.github.com/BitPuffin/f8ad6fa6f43327a84611
> [...]
Make the following changes:
* Replace the call of CHICKEN_initialize in src/init.c by
CHICKEN_run(C_toplevel). This will ensure that the runtime system is
initialized *and* all top-level Scheme code that may do further
initialization work has been executed once.
* Add (return-to-host) to the end of src/itest.scm. This will ensure
that the call to CHICKEN_run actually returns after all initialization
work has been completed.
Then your code should work as expected :-)
Ciao,
Thomas
--
When C++ is your hammer, every problem looks like your thumb.