[cffi-devel] Enumerations cannot contain duplicate values
Rayiner Hashem
rayiner at gmail.com
Thu Sep 1 23:28:59 UTC 2005
Hello! I've encountered some behavior in C-FFI that I would like to discuss.
When you try to define an enumeration containing duplicate values, C-FFI
gives the error:
"A foreign enum cannot contain duplicate values: 0."
However, C enumerations can contain duplicate values, and this feature is
used by real code. FLTK, for example,
uses it to provide for source compatibility when the name of enumeration
elements are changed. Without direct
C-FFI support for this feature, the resultant C-FFI bindings do not
translate well to what the user expects (enumeration
keys available in the C header are not available in the Lisp binding).
Verrazano works around this issue right now (by discarding duplicate keys),
but it's a sub-optimal solution,
since there is no way to programatically determine a consistent set of keys
to discard. For example,
FLTK contains an enumeration in which FL_ALIGN_TOP_LEFT and
FL_ALIGN_LEFT_TOP alias each other,
and FL_ALIGN_TOP_RIGHT FL_ALIGN_RIGHT_TOP alias each other. Depending on the
ordering in the header file,
the enumeration may end up containing an inconsistent set of names (eg:
FL_ALIGN_TOP_LEFT and FL_ALIGN_RIGHT_TOP).
Sincerely,
Rayiner Hashem
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20050901/7a2c6c90/attachment.html>
More information about the cffi-devel
mailing list