More for bitfields

bearophile bearophileHUGS at lycos.com
Sun Jul 4 05:20:33 PDT 2010


This blog post shows possible ideas to make std.bitmanip.bitfields more complete:
http://potential-lang.org/2010/07/02/quasi-quoting-ascii-art-to-define-data-structures/

An example of the ideas:
struct IntDesc_t {
  ...
  immutable IST : 3 = 0;
  immutable Unused0 : 5 = 0;
  immutable type : 4 = 0b1110;
  immutable Unused1 : 1 = 0b0;
  dpl : 2;
  p : 1;
...

That means allowing the fields to have an optional initialization value. And they can be flagged to be immutable too :-) Bit fields that can't change are common.

Bye,
bearophile


More information about the Digitalmars-d mailing list