【发布时间】:2018-10-05 21:55:28
【问题描述】:
我正在编写一个最终可以在 C 代码中使用的 Chicken Scheme 库。为此,我从我的 Scheme 代码中定义了入口点 my_entrypoint。 my_entrypoint 采用 C 回调进行计算:
(define-external (my_entrypoint ((function void (void)) compute)) void
(let ([x (compute)])
...))
(return-to-host)
如何调整第 2 行,以便我的库能够正确构建和运行。照原样,我的代码崩溃并显示以下错误日志:
$ ./test
Error: call of non-procedure: #<pointer 0x10f47fb75>
Call history:
test.scm:5: return-to-host
test.scm:2: compute
这是一个使用我的库的 C 程序示例:
#include <chicken.h>
int compute_something(void)
{
return 42;
}
void my_entrypoint(void (*)(void));
int main()
{
C_word k = CHICKEN_run(C_toplevel);
(void)k;
my_entrypoint(&compute_something);
return 0;
}
【问题讨论】:
标签: chicken-scheme