This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How to change bit-field allocation
- From: Etienne Lorrain <etienne_lorrain at yahoo dot fr>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 7 Sep 2004 16:59:51 +0200 (CEST)
- Subject: Re: How to change bit-field allocation
Min ZOU wrote:
> Robert Dewar wrote:
> > I guess that the problem is that he wants a magical way of dealing with
> > endian differences between processors. Many people want this, but
> > unfortunately there is no coherent consistent way of doing this.
> > This topic has been much studied and discussed in the Ada world :-)
>
> The problem is not due to endian differences but compiler differences. I >
came across this problem when I have to combine two binary images while
> are compiled by different compilers: one by GCC, the other by SH
> proprietary compiler. However the bit-field's members are allocated from
> the lower bit in GCC, while from higher bit in SH compiler.
I had the impression that only one logical way was possible depending
on the processor, so that:
union {
unsigned char val1;
unsigned val2 : 8;
unsigned char val3[1];
struct { unsigned char c1, c2; } val3;
... whatever ...
} a_union;
the value of "a_union.val1", "a_union.val2", "a_union.val3[0]" and
"a_union.val3.c1" are identical - assuming 8 bits chars.
Same for (assuming 16 bits shorts):
union {
unsigned short val1;
unsigned val2 : 16;
enum { e1, e2, e3 } val3 : 16;
} union2;
Etienne.
Vous manquez d?espace pour stocker vos mails ?
Yahoo! Mail vous offre GRATUITEMENT 100 Mo !
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/
Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour dialoguer instantanément avec vos amis. A télécharger gratuitement sur http://fr.messenger.yahoo.com