Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!wuarchive!waikato.ac.nz!comp.vuw.ac.nz!actrix!templar!jbickers From: jbickers@templar.actrix.gen.nz (John Bickers) Newsgroups: comp.sys.amiga.misc Subject: Re: Bitfields in C Message-ID: <3362.tnews@templar.actrix.gen.nz> Date: 8 May 91 08:43:57 GMT References: <214.2826444A@weyr.FIDONET.ORG> Organization: TAP, NZAmigaUG. Lines: 18 Quoted from <214.2826444A@weyr.FIDONET.ORG> by David.Plummer@p0.f70.n140.z1.FIDONET.ORG (David Plummer): > Does anyone know how to build an easily- addressable bitfield array in > C? Exactly what I would like to be able to do it this: Failing anything else, you could try using a macro. So allocate your bitfield array like this: ULONG mybits[(NUM_FIELDS + 31)/32]; #define GETBIT(x) ( (mybits[x >> 5] & (1L << (x & 31L))) ) Etc. You might find it nicer to use tables of masks, or functions instead of macros, etc. > David Plummer - via FidoNet node 1:140/22 -- *** John Bickers, TAP, NZAmigaUG. jbickers@templar.actrix.gen.nz *** *** "Endless variations, make it all seem new" - Devo. ***