如何从调用ffi:c-inline
?
我尝试了以下变体而没有成功(ORGANIZATION
是constants.h中定义的常量):
(ffi:clines "#include \"./constants.h\"")
(ffi:c-inline () () :string "ORGANIZATION" :one-liner t)
上面的示例导致以下编译器错误:
未知的代表类型:STRING
答案 0 :(得分:5)
使用:cstring
代替:string
:
constants.h:
#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://common-lisp.net/project/ecl/static/ecldoc/Extensions.html#Primitive-Types