Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!oliveb!pyramid!ctnews!mitisft!kemnitz From: kemnitz@mitisft.Convergent.COM (Gregory Kemnitz) Newsgroups: comp.lang.c Subject: Re: bitfields considered harmful? Summary: As long as the bitfield is ALWAYS a bitfield... Message-ID: <664@mitisft.Convergent.COM> Date: 2 May 89 18:39:54 GMT References: <1473@uwbull.uwbln.UUCP> <885@twwells.uucp> Distribution: comp Organization: Convergent Technologies, San Jose, CA Lines: 20 In article <885@twwells.uucp>, bill@twwells.uucp (T. William Wells) writes: > In article <1473@uwbull.uwbln.UUCP> ckl@uwbln.UUCP (Christoph Kuenkel) writes: > : We have some software using C bitfields like in > : > : struct ... { > : unsigned active : 1, > : waiting : 1; > : ... > : }; > : I BELIEVE (I may be wrong) that if a bitfield field (need a better word) is NEVER used for ANYTHING ELSE (like masks, etc), then code that uses bitfields is portable (at least between 680X0's and 386's). However, when you use a bitfield field with masks and attempt to set the bitfield field and hope the constitutient bitfields are set right, then you are making (nonportable) assumptions about the bit ordering in your machine. Therefore NEVER use bitfield fields for anything else but bitfields. Greg Kemnitz