www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/03/24/19:29:52

Date: Wed, 24 Mar 93 15:57:28 PDT
From: Peter Crowley <pcrowley AT qdeck DOT com>
To: peprbv AT cfa0 DOT harvard DOT edu, djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: structure packing

>Can I force djgcc to pack structures?  I'm reading headers of ZIP and other
>archive files, and these do not have fields nicely aligned.  In the EMX
>documentation, I found #pragma pack(1), but this doesn't seem to do anything
>to djgcc.

You have to pack the structure elements as needed in gcc 2.2.2. I do not know
about 2.3.x.

#ifdef __GNUC__ /* HJB/POHC */
#define PACKED __attribute__ ((packed));
#else
#define PACKED
#endif

struct s_attach {
        short           result;
        ulong           conhan PACKED;
        };

This will make sizeof(struct s_attach) == 6 rather then 8.

Peter Crowley
Quarterdeck Offices Systems
pcrowley AT qdeck DOT com
 


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019