Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Maarten Brock
09/11/12 03:26
Read: 684 times
The Netherlands

#188306 - no defined bit order
Responding to: Per Westermark's previous message
Per Westermark said:
Next thing - you show sample code with union + C bit fields. But note that bit fields is a C construct to store multiple small state information fields more compactly into a larger integer. The C language do not have bit variables, and the bit field construct is intended to make the C source code look like it accesses normal struct member fields while the compiler performs logical and/or/not operations to set/clear bits within the containing byte.
The C bit fields are always stored side-by-side (with optional high or low padding) in a container integer of an appropriate size.

True, but also note:

C-standard said:
The order of allocation of bit-fields within a unit (high-order to low-order or low-order to high-order) is implementation-defined.

This means that the compiler gets to choose which order it uses (globally, not case-by-case) and another compiler can make a different choice.

List of 11 messages in thread
Different variable bit merge into single variable?      Yagnesh Mehta      09/10/12 04:48      
   Of course      Per Westermark      09/10/12 05:02      
      its bit addressable....      Yagnesh Mehta      09/10/12 05:38      
         No      Per Westermark      09/10/12 06:39      
            just want to check...      Yagnesh Mehta      09/10/12 22:16      
               What was missing in the answers you have already received?      Per Westermark      09/11/12 00:21      
                  no defined bit order      Maarten Brock      09/11/12 03:26      
                     Just use C expression      David Prentice      09/11/12 05:39      
         what is wrong with IE?      Erik Malund      09/10/12 07:01      
            Right!!!!!!!!!!      Yagnesh Mehta      09/13/12 00:29      
               gobbledygook      David Prentice      09/13/12 05:09      

Back to Subject List