Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!mcvax!ukc!reading!cf-cm!sme From: sme@computing-maths.cardiff.ac.uk (Simon Elliott) Newsgroups: comp.lang.c Subject: Re: bitfields considered harmful? Summary: Save space - Really? Message-ID: <705@cf-cm.UUCP> Date: 2 May 89 13:59:32 GMT References: <1473@uwbull.uwbln.UUCP> Distribution: comp Organization: University of Wales College of Cardiff, Cardiff, WALES, UK. Lines: 26 In article <1473@uwbull.uwbln.UUCP>, ckl@uwbln.UUCP (Christoph Kuenkel) writes: > We have some software using C bitfields like in > > [deleted] > > I like them cause they save space and are much more readable than > oriing/anding with # defines and i dont have to bother with questions like > how many flags fit into one int. Well, you may be right about readability, but I don't think you'll find that you've saved much space in your program. Oh, you might save it in the source, but the same shifting and masking is going on under the hood. Now to the real question - how much space have you saved by packing the data? probably not a lot, unless you are using tens of booleans. How much space have you wasted by generating code to shift and mask? Depends how often you look at the flag, right? Whether or not you save space is a trade-off, like so many of these religiously-held ideas. There is no universally-right answer. -- -------------------------------------------------------------------------- Simon Elliott Internet: sme%v1.cm.cf.ac.uk@nsfnet-relay.ac.uk UWCC Computer Centre JANET: sme@uk.ac.cf.cm.v1 40/41 Park Place UUCP: {backbones}!mcvax!ukc!reading!cf-cm!sme Cardiff, Wales PHONE: +44 222 874300