Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!gatech!emory!dtscp1!tridom!wht From: wht@tridom.uucp (Warren Tucker) Newsgroups: comp.lang.c Subject: Re: "address" of a bitfield Message-ID: <157@tridom.uucp> Date: 17 Jul 89 15:31:22 GMT References: <2840@blake.acs.washington.edu> Organization: Tridom Corporation, Marietta GA Lines: 14 In article <2840@blake.acs.washington.edu>, wiml@blake.acs.washington.edu (William Lewis) writes: > > BitFAddr(thing.field, start, offset, width); > which would assign to 'start' the (char *) pointing to the start of the > bitfield, to 'offset' the number of bits into the char the bitfield starts, > and to 'width' the width of the bitfield in bits. Using this info, I > could read & write the bitfield using '<<' and the bitwise operators. > Completely non-portable, but that may be ok for you (the actual format of bit fields are are left to the compiler writer's whim). Try passing the address of the structure to a function that knows which field to manipulate. The best way to be portable would be to scrap bitfields alllll tooogether and use #defines for bit masks.