pdoherty926 pdoherty926 - 7 months ago 66
C Question

How can I return a string from a call to ffi:c-inline in ecl?

How can I return a string constant from a call to

ffi:c-inline
?

I've tried variations of the following without success (
ORGANIZATION
is a constant defined in constants.h):

(ffi:clines "#include \"./constants.h\"")
(ffi:c-inline () () :string "ORGANIZATION" :one-liner t)


The example above results in the following compiler error:


Unknown representation type :STRING

Tim Tim
Answer Source

Use :cstring instead of :string:

constants.h:

#define ORGANIZATION "foobar"

ecl.lsp:

(ffi:clines "#include \"./constants.h\"")
(defun myfun ()
  (ffi:c-inline () () :cstring "ORGANIZATION" :one-liner t))

From ecl prompt:

> (compile-file "ecl.lsp" :load t)
...
> (myfun)

"foobar"
> 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download