From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4795 invoked by alias); 7 Sep 2004 14:59:53 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 4768 invoked from network); 7 Sep 2004 14:59:52 -0000 Received: from unknown (HELO web11802.mail.yahoo.com) (216.136.172.156) by sourceware.org with SMTP; 7 Sep 2004 14:59:52 -0000 Message-ID: <20040907145951.77752.qmail@web11802.mail.yahoo.com> Received: from [62.253.198.200] by web11802.mail.yahoo.com via HTTP; Tue, 07 Sep 2004 16:59:51 CEST Date: Tue, 07 Sep 2004 14:59:00 -0000 From: =?iso-8859-1?q?Etienne=20Lorrain?= Subject: Re: How to change bit-field allocation To: gcc@gcc.gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-SW-Source: 2004-09/txt/msg00299.txt.bz2 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