Re: Bitfields from "Daniel Koepke" at Sep 25, 97 08:58:46 pm

From: Andrew Helm (ashe@IGLOU.COM)
Date: 09/26/97


>
> On Thu, 25 Sep 1997, Andrew Helm wrote:
>
> -+Don't use bitfields. The syntax for their use is pretty much the only
> -+thing about them that isn't implementation defined. They may use up more
> -+space than a bitvector system (depending on alignment requirements and
> -+such), and accessing them requires at least as many instructions as
> -+bitvectors. They may be completely portable, but bitvectors are so much
> -+better.
>
> They're not completely portable, though, and their only
> merit lies in the fact that they aren't limited to the
> size of a variable type like bitvectors.

A bit field is completely portable. A bit field is a part of
the ANSI C standard. Just don't rely on anything that is
implementation defined, and you'll be fine. As for the
size of bitfields not being limited: bullshit. A bitfield
can't be greater than 16 bits. (At least, not in a conforming
ANSI C program.)

> Bitfield:
>
>   int bit0 : 1;

This should really be unsigned int or signed int to be
portable.


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST