You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #598, there is some discussion of how to correctly bind a c enum that is used as a flag. In it, @yallop helpfully suggests that the enum construct can be used to obtain a view into the correct width c type. Here, he gives as an example the following code snippet:
let enum_flags = enum "flags"[]~unexpected:(funx -> x)
upon which we can build a view that correctly maps a list of flags into the enum and vice-versa. I am unsure if @yallop meant to literal pass enum an empty list or not, but it seems to be the case that if one passes enum an empty list the view created by enum will throw a Not_found upon receiving any value, as it will vacuously never match an element on the lhs of a tuple in the passed alist.
Is there a way we can use the enum construct to correctly identify the c type the compiler will use to represent a given enum without running into this issue?
In #598, there is some discussion of how to correctly bind a c enum that is used as a flag. In it, @yallop helpfully suggests that the
enum
construct can be used to obtain a view into the correct width c type. Here, he gives as an example the following code snippet:upon which we can build a view that correctly maps a list of flags into the enum and vice-versa. I am unsure if @yallop meant to literal pass
enum
an empty list or not, but it seems to be the case that if one passesenum
an empty list the view created byenum
will throw aNot_found
upon receiving any value, as it will vacuously never match an element on the lhs of a tuple in the passed alist.Is there a way we can use the
enum
construct to correctly identify the c type the compiler will use to represent a given enum without running into this issue?@lpw25
The text was updated successfully, but these errors were encountered: