This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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;



Vous manquez d?espace pour stocker vos mails ? 
Yahoo! Mail vous offre GRATUITEMENT 100 Mo !
Créez votre Yahoo! Mail sur

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]