Article View: gnu.gcc.help
Article #53005Re: gcc & rs6000 packed data structures
From: Andreas Manessinger
Date: Fri, 03 Apr 1992 06:24
Date: Fri, 03 Apr 1992 06:24
35 lines
2242 bytes
2242 bytes
In article <1992Mar31.222837.332@msus1.msus.edu> schuman@msus1.msus.edu writes:
After installing GCC2.0 on an RS-6000, I have been having some problems with
packed data structures. Here is the problem:
Sample Program--
main ()
{
typedef struct {
char a[13];
int b;
} c;
printf("The size = %d", sizeof(c));
}
The output of the program is 20. I want to compile the program so it will pack
the data structure and print out 17. If anyone knows how to make to gcc
compiler not allign its structures on 4 byte boundaries, it would be extremely
helpful.
I think, there is no way of acomplishing that. Most modern processors
require an alignment to word boundaries and especially RISC processors
do so. There are good reasons for implementing such restrictions in
hardware, they make the design of the chip simpler. I can't definitely
say, that the RS6000 is such a processor but I do think so. That
means, a compiler always HAS TO use the `natural' alignment of the
architecture. What `gcc' does is therefore absolutely correct. If you
need a portable format of structures, use XDR routines for data
conversion. They are part of the Sun RPC package.
--
/\ | eMail: "Andreas.Manessinger@xs0001.at" or "man@xs0001.at"
/ \ndreas | pMail: Kaiserstra\3e. 30/26; A-1070 Wien; Austria
/\/\ \ | Work : Gemeinde Wien MD-ADV/Ma; Ref. EPS
/ / \anessinger | Phone: +43 (1) 9350434 or 4039584/13, FAX: 4039584/18
Technical Details
Message-ID:
<MAN.92Apr3072432@ibm320h.at>Path:
arc1-ca.pugleaf.net!sparky!uunet!email!swdsrv.edvz.univie.ac.at!hp4at!xs0001!newsReferences:
<1992Mar31.222837.332@msus1.msus.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,cd98d9a5e5ba716f X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1992-04-02 22:24:38 PST Newsgroups: gnu.gcc.help Path: arc1-ca.pugleaf.net!sparky!uunet!email!swdsrv.edvz.univie.ac.at!hp4at!xs0001!news From: man@xs0001.at (Andreas Manessinger) Subject: Re: gcc & rs6000 packed data structures In-Reply-To: schuman@msus1.msus.edu's message of 1 Apr 92 04:28:37 GMT Message-ID: <MAN.92Apr3072432@ibm320h.at> Lines: 35 Sender: news@xs0001.at (USENET News System) Organization: Gemeinde Wien, MD-ADV/Md Ref. EPS References: <1992Mar31.222837.332@msus1.msus.edu> Date: Fri, 3 Apr 1992 06:24:38 GMT