Question on structure bit fields and portability?

Marc D Bumble marc_bumble@cpinternet.com
Sat May 10 18:51:00 GMT 2003


I  found a  brief flicker  of a  discussion deriding  C  structure bit
fields as  not being  portable.  The reason  given was  basically that
structures can  be padded differently on  different architectures.  If
one uses  or expects the gcc  compiler across a  variety of platforms,
does that help alleviate the portability problem with bit fields?  Why
is it that compilers do  not automatically solve the bit field problem
consistently for  each given architecture?  Can someone  explain to me
the problem, or is there a better place for me to send this question?

Also, if bit  fields are a problem, what is  most eloquent solution to
solving  the   bit  reading  problem   in  terms  of   efficiency  and
readability?  Is there  a preferred and accepted method  to handle bit
fields?

Thanks,

marc

-- 



More information about the Gcc-help mailing list