🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #51450

None

#51450
From: 0012310
Date: Tue, 18 May 1993 04:30
61 lines
2462 bytes
From: Holcomb, Michael J
Date: Mon, May 17, 1993 3:42 PM
To: GNU C Complier

I am using the GNU C compiler running on the SUN for a target MC68040 
processor.  I would like to know if there is a way to specify that structures 
be packed on 1-byte boundaries.  I am working with the following structures:

typedef struct
  {
  unsigned Start_Byte   : 8;
  unsigned Message_Type : 8;
  } Message_Header_Type;

typedef struct
  {
  unsigned Checksum_0_6  : 8;
  unsigned Checksum_7_13 : 8;
  unsigned End_Byte      : 8;
  } Message_Trailer_Type;

typedef struct
  {
  unsigned Bute_1 : 8;
  unsigned Byte_2 : 8;
  unsigned Byte_3 : 8;
  } Message_Body_Type;

typedef struct
  {
  Message_Header_Type  Message_Header;
  Message_Body_Type    Message_Body;
  Message_Trailer_Type Message_Trailer;
  } Output_Message_Type;

Using the 'sizeof' operator on each of the above structures gives me the 
follow results: 
         sizeof (Message_Header_Type)  = 2
         sizeof (Message_Body_Type)    = 4
         sizeof (Message_Trailer_Type) = 4
         sizeof (Output_Message_Type)  = 10

It seems that any structure with an odd number of bytes get padded with an 
extra byte so that it stays aligned on a word boundary.  This extra padding 
byte on the two Message_Boby and Message_Trailer structures is causing 
problems in my coding application.

Most compilers have a 'pack' or 'align' specifier to cause structure members 
to be packed into memory on 1-byte, 2-byte, or 4-byte boundaries.  If your 
complier has any switches or a #pragma preprocessor directive to force 1-byte 
packing please let me know.  Your assistance to my problem would be 
appreciated.

Thank You,

  Mike Holcomb
  Hughes Aircraft Company
  P.O Box 3310 M/S 604/E222
  Fullerton, CA 92634 

  Internet 0012310@msgate.emis.hac.com 
Technical Details
Message-ID: <9305172352.AA25721@hac2arpa.hac.com>
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!math.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!msgate.emis.hac.COM!0012310

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,a4228877816c1170,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-05-17 21:39:30 PST
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!math.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!msgate.emis.hac.COM!0012310
From: 0012310@msgate.emis.hac.COM
Newsgroups: gnu.gcc.help
Subject: None
Date: 18 May 1993 00:30:50 -0400
Organization: GNUs Not Usenet
Lines: 63
Sender: daemon@cis.ohio-state.edu
Distribution: gnu
Message-ID: <9305172352.AA25721@hac2arpa.hac.com>