HomeUpSign my Guestbook!RSS • Published: 2026-03-07 • Powered by IPFS

CFFI Struct Vectors


(asdf:load-system :cffi)

(cffi:defcstruct point
  (x :int)
  (y :int))

(cffi:with-foreign-object (vec '(:struct point) 4)
  (loop
    :with idx := 0
    :for i :to 4
    :do
       (cffi:with-foreign-slots 
         ((x y)
          (cffi:mem-aptr vec '(:struct point) i)
          (:struct point))
         (setf
          x (incf idx)
          y (incf idx))))
  (sb-vm:hexdump vec))