https://issues.dlang.org/show_bug.cgi?id=23573
[email protected] changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #2 from [email protected] --- (In reply to johanengelen from comment #1) > I thought that `std.bitmanip.bitfields` does not give any guarantees on > layout, just that it tries to pack bits in minimal storage space. > For example also no guarantees when sending std.bitmanip.bitfields as > ubyte[] over network connection to a PC with different OS/arch. > Removal of guarantees (like no guarantees of class layout) enables > reordering of fields if it is beneficial to prevent accessing multiple > bytes/words for multibyte fields: > mixin(bitfields!( > bool, "flag1" , 1, > ubyte, "flag2", 8, // spans 2 bytes or one byte? > bool, "sign" , 1)); > > Because D bitfields are meant to mimic C bitfields, I think it will be very > hard to guarantee that the layout of std.bitmanip.bitfields is the same... D doesn't need two undefined flavours of bitfields. Some people find it useful to be able to read bitfields from files or the network regardless of cpu architecture. --
