From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,9af04b2baa5a026a X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2003-03-20 11:55:53 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!agate.berkeley.edu!agate!not-for-mail From: David Konerding Newsgroups: comp.unix.tru64 Subject: Re: Data structure alignment question Date: Thu, 20 Mar 2003 19:55:53 +0000 (UTC) Organization: University of California, Berkeley Message-ID: References: <8df11a0.0303191636.389f8f0c@posting.google.com> Reply-To: dek@compbio.berkeley.edu NNTP-Posting-Host: wuzzy.berkeley.edu X-Trace: agate.berkeley.edu 1048190153 81130 128.32.236.47 (20 Mar 2003 19:55:53 GMT) X-Complaints-To: usenet@agate.berkeley.edu NNTP-Posting-Date: Thu, 20 Mar 2003 19:55:53 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.unix.tru64:9742 In article <8df11a0.0303191636.389f8f0c@posting.google.com>, Marc S. Gibian wrote: > I am porting a program that runs on a number of other Unix/Linux > platforms to Tru64 5.1, GCC 3.2.2. This program interchanges messages > via sockets with other systems. Thus, the data alignment in > structures/classes is critical. To my surprise, I find that my data is > begin laid out more compactly than on the other platforms. It seems > like there must be a pragma or other mechanism within GCC that would > allow me to instruct the compiler to align the data on long word (32 > bit) boundries. If not, I'm going to be stuck adding pad fields to a > non-trival set of structures. Hi, The "info" pages, which are included with the gcc distribution, have a page on this, "Variable attributes" which explain how to specify the alignment and packing of structures. However, your message seems to suggest that you are writing the binary data of a structure directly over the network. Is that correct? If so, you should be aware many people consider this a poor solution because it's not very portable. I always use some intermediate data encoding which ensures portable behavior (in my case CORBA, but other data encoders exist). Dave