[Cffi-devel] defcstruct &key size

Luís Oliveira luismbo at gmail.com
Sun Nov 2 19:14:08 UTC 2014


On Sat, Nov 1, 2014 at 9:09 PM, FAU <fau at riseup.net> wrote:
> Apparently SIZE is not evaluated at macro expansion time.
>
> I basically want to pass the name of a foreign function as SIZE and have
> it evaluated.
[...]
> (macrolet
>     ((m ()
>         `(cffi:defcstruct (foo-struct :size ,(eval-when
> (:compile-toplevel :load-toplevel :execute) (foo-size)))
>                           (data :pointer))))
>   (m))

Do you really need to define a struct type? Can you get away with
something like (with-foreign-object (p :char size) ...)?

-- 
Luís Oliveira
http://kerno.org/~luis/




More information about the cffi-devel mailing list