From the API documentation:

Create a bitfield pack of eight bits, which fit in one ubyte.
[...]

struct A
{
    mixin(bitfields!(
       bool, "flag1",    1,
       bool, "flag2",    1,
       uint, "",         6));
}

A a;
writeln(a.flag1); // 0
a.flag1 = 1;
writeln(a.flag1); // 1
a.flag1 = 0;
writeln(a.flag1); // 0
writeln(a.sizeof);


Application output

false
true
false
16

I would expect a sizeof 1. Why is its size 16 ?

Source: https://dlang.org/library/std/bitmanip/bitfields.html

Reply via email to