This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Question on structure bit fields and portability?
- From: Marc D Bumble <marc_bumble at cpinternet dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Sat, 10 May 2003 14:51:43 -0400
- Subject: Question on structure bit fields and portability?
- Reply-to: mbumble at cpinternet dot com
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
--