🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #50244

Packed structures?

#50244
From: Bjorn Halvor Solberg
Date: Thu, 04 Nov 1993 11:29
34 lines
2031 bytes
I am wondering if gcc is able to produce packed structures, i.e. make a
struct like

struct mystruct {
  char field1;
  int field2;
  double field3;
};

use sizeof(char)+sizeof(int)+sizeof(double) bytes instead of using
sizeof(char)+padding+sizeof(int)+padding+sizeof(double) bytes. That would
make it much easier to read binary headers in one chunk instead of reading
each field separately.

I am using gcc-2.4.5 on a Sparc (Sun4.1.1). The documentation mention some
#pragma interface, but not for the Sparc architecture. Is there a switch or
anything else that can make gcc avoid padding the structs? Will installing
gcc-2.5.X help? If so, how?

Thanks for any response,


Bjorn H. Solberg                                                o
(bhso@fou.tr.statoil.no)                                           \
Statoil R&D, Trondheim, Norway             ||====================\O/==||
Phone  : +47 73 58 47 29                   ||-+-+-+-+-+-+o+-+-+-+-J-+-||
Fax    : +47 73 96 72 86                   ||==O========<O>=======/\==||
Address: Postuttak,                        ||  T\o       A        \ \ ||
         N-7004 TRONDHEIM                  || / )       ( )           ||
         NORWAY                        
-----------------------------------                           
                             

  
Technical Details
Message-ID: <1993Nov4.112923.9713@statoil.no>
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!sol.ctr.columbia.edu!math.ohio-state.edu!cs.utexas.edu!uunet!pipex!sunic!trane.uninett.no!news.eunet.no!nuug!statoil!fou.tr.statoil.no!bhso

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,dbab544dff24be7f,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-11-04 04:06:34 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!sol.ctr.columbia.edu!math.ohio-state.edu!cs.utexas.edu!uunet!pipex!sunic!trane.uninett.no!news.eunet.no!nuug!statoil!fou.tr.statoil.no!bhso
From: bhso@fou.tr.statoil.no (Bjorn Halvor Solberg)
Subject: Packed structures?
Message-ID: <1993Nov4.112923.9713@statoil.no>
Sender: usenet@statoil.no
Nntp-Posting-Host: und36.fou.tr.statoil.no
Reply-To: bhso@fou.tr.statoil.no
Organization: Statoil R&D, Trondheim
Date: Thu, 4 Nov 1993 11:29:23 GMT
Lines: 34