The current issues with bitfields and unions aside, it may be generally useful to conditionalize code on the size/alignment of C types. C does not enjoy the neat determinism we have in Rust (and people had to fight to get it here), but we need to interface with C APIs without silly structure copying and excessive typecasts. There apparently was demand for target_pointer_size, which is the same idea limited to the pointer types.
Bitfields are going to be a marginal concept in Rust, so I’d argue #[repr] is where they belong.
I’m thinking of something along the lines of:
#[repr(C; bitfields(foo: 2, bar: 1))]
struct A {
foo: c_uint,
bar: c_uint
}
As FFI should be the only application for bit fields in Rust, setting them could be made unsafe, to punt on the implications of exceeding the range.