On 2005-dec-11, at 06:48, Jack Unrue wrote:
My goal is simply to declare structs whose C equivalent includes array members. I'm not sure how the array declaration would be done in CFFI so I'll use LispWorks FLI instead:
(fli:define-c-struct foo (data (:c-array :int 32)) (id :int))
This would translate to: (cffi:defcstruct foo (data :int :count 32) (id :int)) The plan is that you would access an element of this array using (cffi:foreign-slot-value foo-obj 'foo 'data <index>). However, this is not implemented yet so, for the time being, you'll need to use something like: (cffi:mem-aref (cffi:foreign-slot-value foo-obj 'foo 'data) :int <index>) Or: (cffi:with-foreign-slots ((data) foo-obj foo) (cffi:mem-aref data :int <index>)) This is not to say that an array type is not needed. I think we'll need one in order to access multi-dimensional arrays conveniently. -- Luís Oliveira http://student.dei.uc.pt/~lmoliv/ Equipa Portuguesa do Translation Project http://www.iro.umontreal.ca/translation/registry.cgi?team=pt