[cffi-devel] hard to find bugs pop up when working with enums :(

Lars Rune Nøstdal larsnostdal at gmail.com
Wed Dec 20 11:29:12 UTC 2006


..say I have this:

  SWGtk> (defcenum UpdateType :continuous :discontinous :delayed)

..then do:

  SWGtk> (foreign-enum-value 'UpdateType :not-valid)

..I get a meaningful message from CFFI:

  :not-valid is not defined as a keyword for enum type #<cffi::foreign-enum UpdateType>.

..very nice; as expected. But if I do:

  SWGtk> (foreign-funcall "someCFunction" UpdateType :not-valid)

..I get:

  The value nil is not of type (signed-byte 32).

It is almost impossible to debug this because I cannot see any NIL
anywhere. :not-valid is a constant here of course - but if it is in a
variable:

  SWGtk> (foreign-funcall "someCFunction" UpdateType some-variable)

..`some-variable' _still_ doesn't contain NIL so I've been lost for quite
some time here.

-- 
Lars Rune Nøstdal
http://nostdal.org/





More information about the cffi-devel mailing list