"address" of a bitfield

Roger Critchlow rec at elf115.uu.net
Tue Jul 18 02:04:36 AEST 1989


In article <2840 at blake.acs.washington.edu>, wiml at blake.acs.washington.edu (William Lewis) writes:
> 
> [reasonable reasons for wanting the address of a bitfield]
>
>     Does anyone know of an even semi-portable way to do this? Or, if
> there is no portable way, a way that works with Mark Williams C on
> a MSDOS machine? 

There isn't currently any way to do this with the Mark Williams compiler,
and there is no way to do this defined by the dpANS.

But, I note that the result of the dpANS offsetof() macro is undefined
when applied to a bitfield member, and if a compiler treated this macro
with special care it might be possible to provide the necessary infor-
mation for those who need it.

One possibility would be for offsetof(type, bit-field-member) to generate
a triple of constants:

  bit_offset_constant, bit_width_constant, byte_offset_constant

which could be plugged into a user defined function call argument list to
a bit field pointer constructor.

Does anyone see any problems with this as an extension to dpANS?

-- rec at elf115.uu.net --



More information about the Comp.lang.c mailing list