Article View: gnu.gcc.help
Article #42250Packing data and structs
From: Paul Repper
Date: Thu, 04 Jan 1996 00:00
Date: Thu, 04 Jan 1996 00:00
40 lines
1649 bytes
1649 bytes
I am rehosting a program from the PC to a SUN SPARC10 station and need to get the
data and structures packed. For the PC I used a #pragma pack(1) in a global
header file and then set the compiler option to pack structures on 1-byte
boundaries. Two of two example structures are as follows:
typedef struct ddfdef {
char datatype;
INT16 entrycount;
INT16 firstentry;
INT16 lastentry;
} DDFDEF;
typedef struct ddfdir {
INT16 paramcount;
INT32 recordcount;
INT16 recordsize;
INT8 recordtype;
INT8 filenumber;
INT8 datasetnum;
char datatype;
INT16 recordingsession;
INT16 nextentry;
} DDFDIR;
Structure DDFDEF should pack to a size of 7 while DDFDIR should pack to 16.
Using "__attribute__((packed))" on each structure is successful for DDFDIR but
complains about being a power of 2 for DDFDEF and maintains a size of 8.
Thus one structure does not get packed.
I really need everything packed and am looking for a global method of doing this
(i.e. a command in the make file or such). Is there a way of accomplishing
this?
Oh, I have defined BITS_PER_WORD to be 16 and UNITS_PER_WORD as 2.
Thanks in advance for any help!!
Paul Repper
Repper_Paul@si.com
Technical Details
Message-ID:
<DKo8EC.6y1@esseye.si.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,8fa06a2b28fb045c,start X-Google-Attributes: gid11318c,public From: repper@esseye.si.com (Paul Repper) Subject: Packing data and structs Date: 1996/01/04 Message-ID: <DKo8EC.6y1@esseye.si.com> X-Deja-AN: 133957232 distribution: usa organization: Smiths Industries keywords: packing newsgroups: gnu.gcc.help summary: Need to globally pack data and structs