How to change bit-field allocation

Ramana Radhakrishnan ramana.r@gmail.com
Mon Sep 6 17:15:00 GMT 2004


Hi Min, 

> HI,
> 
> As I know, GCC allocates bit-fields inside a structure from the lowest
> addressed byte, i.e. LSB, for little endian. However, I want to reverse
> the ordering for the bit-fields allocation, i.e. always from MSB.

The info pages seem to say and I quote 

<begin quote>

— Macro: BITS_BIG_ENDIAN

    Define this macro to have the value 1 if the most significant bit
in a byte has the lowest number; otherwise define it to have the value
zero. This means that bit-field instructions count from the most
significant bit. If the machine has no bit-field instructions, then
this must still be defined, but it doesn't matter which value it is
defined to. This macro need not be a constant.

    This macro does not affect the way structure fields are packed
into bytes or words; that is controlled by BYTES_BIG_ENDIAN.

— Macro: BYTES_BIG_ENDIAN

    Define this macro to have the value 1 if the most significant byte
in a word has the lowest number. This macro need not be a constant.

<end quote>

http://gcc.gnu.org/onlinedocs/gccint/Storage-Layout.html#Storage-Layout 



cheers
Ramana

-- 
Ramana Radhakrishnan



More information about the Gcc mailing list