From: Frank Peelo (fpeelo at domain eircom.net)
Date: Thu 11 May 2000 - 10:27:57 IST
>
> That would be a judgement call, I wouldn't do it. There are a limited
> set of circumstances where such spacesaving will actually make any
> difference in comparison to the amounts of data generally being moved
> around. The only place I use bitfields is to interface with something
> that is already playing such games. The word spec for instance is a good
> example of a data format which does that, and theres certainly loads of
> hardware which sets individual bits and bit ranges which are easier
> handled with bitfields rather than explicit shifting and masking
> yourself.
>
> Someone else said that bitfields are not standard, there are indeed
> ANSI-C
> Though ansi allows only int, unsigned int, or signed int type. So
> technically no char i:3; or long i:3;
K&R second edition seems to disagree (p212). "A structure member may also
consist of a specified number of bits. Such a member is also called a
bit-field, or merely field; its length is set off from the declarator for
the field name by a colon."
It also says "The ANSI standard makes fields even more
implementation-dependent than did the first edition. It is advisable to read
the language rules for storing bit-fields as "implementation-dependent"
without qualification." - which sounds to me like a good reason to avoid
them if possible, unless you can be certain that you are using the same
compiler as the people who wrote the system to which you are interfacing.
Frank
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:06:06 GMT