Closed
Description
Bindgen currently emits unit tests to check layout. However, these are quite difficult to run for a cross-compiled target as there may be no way to run code on the target as part of the build process. Targets not supporting std
, i.e. embedded, are harder again to run the tests on.
With the stabilization of core::mem::offset_of
it should now be possible to convert the layout tests into compile-time assertions like below. This would make it much easier for embedded users to run these tests.
const _LAYOUT_TEST_S: () = {
assert!(::core::mem::size_of::<S>() == 4);
assert!(::core::mem::align_of::<S>() == 4);
assert!(::core::mem::offset_of!(S, field1) == 0);
// etc.
};