Thanks very much for all the help, your advice worked a treat.
One final question, originally I was defining the struct inside
the main loop and it was using 4 bytes per field rather than 2
bits, e.g.:
import std.bitmanip;
import std.stdio;
struct Crumb1
{
mixin(bitfields!(
ubyte, "one", 2,
ubyte, "two", 2,
ubyte, "three", 2,
ubyte, "four", 2));
}
void main()
{
struct Crumb2
{
mixin(bitfields!(
ubyte, "one", 2,
ubyte, "two", 2,
ubyte, "three", 2,
ubyte, "four", 2));
}
writeln(Crumb1.sizeof, " ", Crumb2.sizeof);
}
outputs:
1 16
Is this correect behaviour?
Andrew