Closed
Description
Input C/C++ Header
// We have a lot of enums defined using this macro
#define __UI_ENUM(s) typedef unsigned int s; enum
// Like this
_UI_ENUM(uiAlign) {
uiAlignFill,
uiAlignStart,
uiAlignFill,
uiAlignEnd,
}
Bindgen Invocation
// Generate libui bindings on the fly
let bindings = BindgenBuilder::default()
.header("wrapper.h")
.opaque_type("max_align_t") // For some reason this ends up too large
.generate()
.expect("Unable to generate bindings");
The Issue
I use these enums in Rust code, for instance, here:
// Where GridAlignment is an enum and ui_sys is the bindings
use ui_sys::{self, uiAlign};
impl GridAlignment {
fn into_ui_align(self) -> uiAlign {
use self::GridAlignment::*;
match self {
Fill => ui_sys::uiAlignFill,
Start => ui_sys::uiAlignStart,
Center => ui_sys::uiAlignCenter,
End => ui_sys::uiAlignEnd
}
}
}
On Linux, this code works. On Windows, it does not:
error[E0308]: match arms have incompatible types
--> iui\src\controls\layout.rs:283:9
|
283 | / match self {
284 | | Fill => ui_sys::uiAlignFill,
| | ------------------- match arm with an incompatible type
285 | | Start => ui_sys::uiAlignStart,
286 | | Center => ui_sys::uiAlignCenter,
287 | | End => ui_sys::uiAlignEnd
288 | | }
| |_________^ expected u32, found i32
Check out more details, if needed, at LeoTindall/libui-rs#29
Metadata
Metadata
Assignees
Labels
No labels