Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!dino!atanasoff!hascall From: hascall@atanasoff.cs.iastate.edu (John Hascall) Newsgroups: comp.lang.c Subject: Re: "address" of a bitfield Message-ID: <1226@atanasoff.cs.iastate.edu> Date: 18 Jul 89 15:22:52 GMT References: <2840@blake.acs.washington.edu> <1989Jul17.212555.24509@utzoo.uucp> Reply-To: hascall@atanasoff.cs.iastate.edu.UUCP (John Hascall) Organization: Iowa State Univ. Computation Center Lines: 23 In article henry@utzoo.uucp (Henry Spencer) writes: >In article <@blake.acs.washington.edu> wiml@blake.UUCP (William Lewis) writes: >> 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... >> Does anyone know of an even semi-portable way to do this? ... >Can't be done -- the packing of bitfields into words/chars/whatever is >highly machine-specific (even the order, left-to-right or right-to-left, >varies) and the information is not available to the program. But it is available to the compiler! Which is what I think Mr. Lewis was thinking of--that it be handled like the "sizeof" operator. It seems like useful information, but perhaps separate operators would be more convenient: bit_sizeof(foo) bit_offsetof(foo) bit_baseof(foo) John Hascall / ISU Comp Center / Ames IA