[cffi-devel] foreign-type-size of struct types

Wilco Greven greven at kde.org
Thu Aug 4 12:33:58 UTC 2005


Hello,

I'm using cffi for trying to revive the Qt bindings. Doing so I found out that 
for the calculation of the size of struct types, the alignment of the struct 
itself is not taking into account. For the following struct for example

(defcstruct smoke-class
  (class-name string)
  (parents index)
  (class-fn :pointer)
  (enum-fn :pointer)
  (flags :unsigned-short))

cffi calculates a size of 18, which should be 20 (please correct me if I'm 
wrong). Attached is a patch which defines an extra method for 
foreign-type-size for a foreign-struct-type argument. This method is used to 
apply adjust-for-alignment on the newly defined struct.

Greetings,
Wilco
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cffi.diff
Type: text/x-diff
Size: 1038 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20050804/634f4e8f/attachment.diff>


More information about the cffi-devel mailing list