如何从调用ffi:c-inline返回字符串常量
我尝试过以下的变体,但都没有成功(ORGANIZATION是Constants.h中定义的常量):
(ffi:clines "#include \"./constants.h\"")
(ffi:c-inline () () :string "ORGANIZATION" :one-liner t)上面的示例导致以下编译器错误:
未知表示类型:字符串
发布于 2017-11-30 00:07:09
使用: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#Primitive-Types
https://stackoverflow.com/questions/47562440
复制相似问题