pub enum BitFieldStyle {
Itanium,
Microsoft,
}Expand description
How a target allocates bit-fields into storage.
Everything else about laying a record out is one algorithm reading different sizes and
alignments per target. This is not: the two answers below place the same members at different
offsets and give the same struct different sizes, and no amount of changing what an int is
turns one into the other. struct { unsigned m:3; char c; } is four bytes with the char at
offset one under the first and eight bytes with it at offset four under the second.
Variants§
Itanium
The Itanium C++ ABI’s rule, which every psABI in this table except Windows follows. A
bit-field goes at the next free bit unless that would make it span more storage than its
own type occupies, in which case it starts at the next boundary of its alignment. Storage
is shared between members of different types freely, so struct { char a:3; unsigned b:3; }
is four bytes with both fields in the first one.
Microsoft
Microsoft’s rule, which both Windows environments follow and not only MSVC. A run of
bit-fields is allocated into a unit the size and alignment of the declared type, and the
unit is closed both when the next member’s declared type has a different size and when the
field does not fit in what is left. An ordinary member closes a unit too, and the closed
unit occupies its whole declared size whether or not the bits were used. So the same struct
is eight bytes: a one byte unit for the char and a four byte one for the unsigned,
aligned to four.
Implementations§
Trait Implementations§
Source§impl Clone for BitFieldStyle
impl Clone for BitFieldStyle
Source§fn clone(&self) -> BitFieldStyle
fn clone(&self) -> BitFieldStyle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more