C bitfields guarantees
Daniel N
no at public.email
Wed Jul 10 07:43:40 UTC 2024
On Wednesday, 10 July 2024 at 07:09:10 UTC, Walter Bright wrote:
> I had written a detailed reply, but realized you and I were
> simply running around in the same circle saying the same things.
Maybe some input from 3rd party could help?
I use bitfields daily and never had any issues. What I do is to
always use fix size types and then simply take all freedom away
from the compiler.
uint32_t a;
uint32_t :32; // Forced padding
uint64_t b:10;
uint64_t c:10;
uint64_t :44; // Forced padding
uint32_t d;
I guess one can use 0 size bitfields also but I usually prefer to
visualize how much padding remains for potential future use.
More information about the Digitalmars-d
mailing list