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
Some architectures have small integer types such as AVR, which has 16-bit int.
For preprocessor constants, bindgen emits the constant in Rust as a constant with type libc::c_int. If c_int is i16, large constants can overflow, causing compiler warnings.
This is a pretty obscure bug because it only appears on esoteric platforms with a small int type. At some point bindgen could be modified so that it detects constant overflow and promotes to the next bigger integer type.
Huh, interesting, I'd have bet that we mapped them to actual fixed-sized types.
You can workaround it with ParseCallbacks. This can also be trivially fixed in var.rs, where the type is chosen. It's late for me now, but I'm happy to mentor or take a look tomorrow.
emilio
added a commit
to emilio/rust-bindgen
that referenced
this issue
Feb 4, 2018
Some architectures have small integer types such as AVR, which has 16-bit
int
.For preprocessor constants, bindgen emits the constant in Rust as a constant with type
libc::c_int
. Ifc_int
isi16
, large constants can overflow, causing compiler warnings.This is a pretty obscure bug because it only appears on esoteric platforms with a small int type. At some point bindgen could be modified so that it detects constant overflow and promotes to the next bigger integer type.
Input C/C++ Header
Actual Results
Expected Results
Bindgen maps the preprocessor defines to Rust constants which have types large enough to fit the integer literal.
The text was updated successfully, but these errors were encountered: