gir
gir copied to clipboard
#define big constants overflow i32
When generating bindings for Aravis, there are things like:
#define ARV_PIXEL_FORMAT_CUSTOM_BAYER_BG_12_PACKED 0x810c0004
This codegens into GIR:
<constant name="PIXEL_FORMAT_CUSTOM_BAYER_BG_12_PACKED"
value="2165047300"
c:type="ARV_PIXEL_FORMAT_CUSTOM_BAYER_BG_12_PACKED">
<type name="gint" c:type="gint"/>
</constant>
And then into Rust:
pub const ARV_PIXEL_FORMAT_CUSTOM_BAYER_BG_12_PACKED: c_int = 2165047300;
However this value is too big, and overflows i32
. Either #[allow(overflowing_literals)]
or upping the type would be fixes IMO
Seems you need do this manually:
- add it to
manual
array in gir.toml - add manual.rs with right definition near lib.rs, then on next regen it will be included See https://github.com/gtk-rs/sys/blob/master/gtk-sys/src/manual.rs as example
Alternative is changing constant in .gir file
This is a bug in the C library. It should make sure that a correct type is used for the integer literal, not just a gint
(see XML). Something like the following should do the job:
#define ARV_PIXEL_FORMAT_CUSTOM_BAYER_BG_12_PACKED 0x810c0004U
Thank you for your answers! Just opened https://github.com/AravisProject/aravis/pull/304, let's see how that moves :)
@sdroege Looks like it didn't change anything https://github.com/AravisProject/aravis/pull/304 ; is that normal? (I have no idea how gobject-introspection works :/)
I don't know, it works in GStreamer with the big constants
See https://github.com/AravisProject/aravis/pull/304#issuecomment-545303648
I don't think this is a gir issue, gir does the right thing if the introspection data is correct.