如何从调用到 ffi:c-inline
?
我尝试了以下方面的变化而没有成功(ORGANIZATION
是常数定义的常数。H):
(ffi:clines "#include "./constants.h"")
(ffi:c-inline () () :string "ORGANIZATION" :one-liner t)
上面的示例导致以下编译器错误:
未知表示类型:字符串
使用:cstring
代替:string
:
常量:
#define ORGANIZATION "foobar"
ecl.lsp:
(ffi:clines "#include "./constants.h"")
(defun myfun ()
(ffi:c-inline () () :cstring "ORGANIZATION" :one-liner t))
来自ECL提示:
> (compile-file "ecl.lsp" :load t)
...
> (myfun)
"foobar"
>
参考:https://ecl.common-lisp.dev/static/manual/foreign-function-interface.html#primistive-types