cbindgen
cbindgen copied to clipboard
Enum with assigned values does not get exported as enum
I have an enum like:
#[allow(missing_debug_implementations, missing_copy_implementations, non_camel_case_types)]
#[repr(C)]
#[cfg_attr(test, derive(Copy, Clone, Debug))]
pub enum ErrorCode {
ERROR_EMPTY_LIST = 0,
ERROR_VALUE_UNKNOWN = -1,
ERROR_WRONG_TYPE = -2,
ERROR_VALUE_INVALID = -3,
ERROR_CONTEXT_INVALID = -4
ERROR_DEVICE_NOT_FOUND = -5,
ERROR_GROUP_NOT_FOUND= -6,
ERROR_FIELD_NOT_FOUND = -7,
}
which is not used directly so I export it though export.include
however it ends up as
typedef struct ErrorCode ErrorCode;
Which is quite useless
A similar enum where I don't set the enum values works as expected
For me now enums with assigned values work, but
#[derive(Copy, Clone)]
#[repr(u8)]
pub enum CConnectError {
OK = (ErrorCode::OK as u8),
InvalidState = (ErrorCode::InvalidState as u8),
Unaddressable = (ErrorCode::Unaddressable as u8),
}
results into
typedef struct CConnectError CConnectError;
The second issue seems related to https://github.com/mozilla/cbindgen/issues/591, because the assigned values contain paths?