-[no]bfield_lsbit_first

Changes the default allocation order.

Syntax
  -[no]bfield_lsbit_first  
Default
  -bfield_lsbit_first  
Defines
  __BITFIELD_LSBIT_FIRST__  
  __BITFIELD_MSBIT_FIRST__  
Remarks

By default, during bitfield allocation, bits are allocated from the least significant to the most significant one, in the order of declaration (that is, the first declared bitfield will be leftmost in the allocation unit).

This option is equivalent to the pragma,

#pragma bfield_lsbit_first on | off | reset

Note: Allocation units (either bytes or words) are always allocated in memory from the smallest to the highest address (that is, the first allocation unit will be at the smallest address in memory).

The following example demonstrates how this option works:

Listing: Example bfield_lsbit_first
typedef struct {
        unsigned char b0: 1;

        unsigned char b1: 1;

        unsigned char b2: 1;

        unsigned char b3: 1;

        unsigned char b4: 1;

        unsigned char b5: 1;

        unsigned char b6: 1;

        unsigned char b7: 1;

        unsigned char b8: 1;

        unsigned char b9: 1;

        unsigned char b10: 1;

        unsigned char b11: 1;

        unsigned char b12: 1;

        unsigned char b13: 1;

        unsigned char b14: 1;

        unsigned char b15: 1;

} SomeStruct;

Assuming we initialize an instance of SomeStruct as below:

  SomeStruct s = {1,0,1,0,0,0,0,0,1,1,1,0,0,0,0,0};  

we get the following memory layouts for s:

  -bfield_lsbit_first (default)   : 05 07 ( 
  [b7|b6|b5|b4|b3|b2|b1|b0] 
  [b15|b14|b13|b12|b11|b10|b9|b8] )
  
  -nobfield_lsbit_first           : A0 E0 ( 
  [b0|b1|b2|b3|b4|b5|b6|b7] 
  [b8|b9|b10|b11|b12|b13|b14|b15] )
  

For more information, refer to the pragma bfield_lsbit_first.