🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #42356

Re: q: structrue packing

#42356
From: Friedemann Baitinger
Date: Thu, 14 Dec 1995 00:00
29 lines
1469 bytes
c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) wrote:

>In article <30c84575.17614502@news.toplink.de>,
>Friedemann Baitinger <baiti@herrenberg.netsurf.de> wrote:
> >how can i instruct the gcc compiler to generate packed structures?
> >
> >#define BYTE1 unsigned char
> >#define BYTE2 unsigned short
> >#define BYTE4 unsigned long
> >
> >typedef struct {
> >    BYTE2 b21;
> >    BYTE2 b22;
> >    BYTE2 b23;
> >    BYTE4 b41;
> >} some_t;
> >
> >in this example, i always get a two byte gap between b23 and b41.
> >sizeof(some_t) evaluates to 12 instead of 10.
>
>Did you read the man page? Try -mno-strict-align, it might do the trick.

yes i did. this option is not supported on i486 -mold-align isn't either.
by trial and error i found a way that works:  #pragma pack(1)
---
Regards, Gruesse,
Friedemann Baitinger                 internet:  baiti@vnet.ibm.com
                                       office:  IPNET(BAITI)
IBM Boeblingen Lab., Germany            phone:  49-7031-16-4166
Technical Details
Message-ID: <4aorla$pvh@grimsel.zurich.ibm.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <30c84575.17614502@news.toplink.de> <4ak7mbINNfrc@keats.ugrad.cs.ubc.ca>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,4ec01187e2d9ea4e
X-Google-Attributes: gid11318c,public
From: baiti@raleigh.ibm.com (Friedemann Baitinger)
Subject: Re: q: structrue packing
Date: 1995/12/14
Message-ID: <4aorla$pvh@grimsel.zurich.ibm.com>
X-Deja-AN: 121854798
references: <30c84575.17614502@news.toplink.de> <4ak7mbINNfrc@keats.ugrad.cs.ubc.ca>
organization: IBM Zurich Research Laboratory
newsgroups: gnu.gcc.help