Why must butfields sum to a multiple of a byte?

monarch_dodra monarchdodra at gmail.com
Mon Jul 30 10:50:08 PDT 2012


On Monday, 30 July 2012 at 17:15:54 UTC, Andrej Mitrovic wrote:
> On 7/30/12, Ali Çehreli <acehreli at yahoo.com> wrote:
>> The program should be able to detect the placements of the 
>> fields. You
>> can expect a certain bit pattern for a given set of values of 
>> the bit
>> fields, set those values, read them on the D side, detect 
>> potential
>> inconsistencies, and fail the execution (or hopefully 
>> compilation).
>
> Yeah that was exactly my thinking, these things can be automated
> although they might slow down the whole codegeneration process a
> little bit (not that it matters much since you would rarely 
> have to
> regenerate).
>
> Btw, I get an internal std error with this mixin:
>
> import std.bitmanip;
> struct Foo
> {
>     mixin(bitfields!(
>         uint, "bits1", 32,
>     ));
> }
>
> D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d(76): 
> Error:
> shift by 32 is outside the range 0..31
>
> Should I file this?

Yes, that should work.

By the way, what's a "butfield"?


More information about the Digitalmars-d-learn mailing list