I think we should just drop the padding altogether and don't compare the structure size in tests. The primary reason for that is failing static_assert on 32-bit architectures (Raspberry Pi Zero for example). It's due to the std::string or std::map containing pointers to memory that take more 4 bytes vs 8 bytes on 64-bit archs (partially reported in https://github.com/lit-robotics/libcamera-rs/issues/17).
We could introduce a more complicated padding like:
void *__padding0[6];
uint8_t __padding1[24];
But I don't feel like this approach has any benefit. The Rust code doesn't make any use of that padding space and only uses that struct through a pointer so only the alignment of the important fields matter and this is already checked with offsetof.
Hi!
I think we should just drop the padding altogether and don't compare the structure size in tests. The primary reason for that is failing
static_assert
on 32-bit architectures (Raspberry Pi Zero for example). It's due to thestd::string
orstd::map
containing pointers to memory that take more 4 bytes vs 8 bytes on 64-bit archs (partially reported in https://github.com/lit-robotics/libcamera-rs/issues/17).We could introduce a more complicated padding like:
But I don't feel like this approach has any benefit. The Rust code doesn't make any use of that padding space and only uses that struct through a pointer so only the alignment of the important fields matter and this is already checked with
offsetof
.