www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/10/17:39:33

From: "A.Appleyard" <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk>
Organization: Materials Science Centre
To: djgpp AT delorie DOT com
Date: Mon, 9 Dec 1996 08:25:49 GMT
Subject: Re: Padding Question
Message-ID: <40009E0A62@fs2.mt.umist.ac.uk>

  Rohit Jalan <rohitj AT m-net DOT arbornet DOT org> wrote (Subject: Padding Question):-
> Is it possible to stop gcc from padding structures ?

  At the top of the program put this line:-

#define pk __attribute__((packed))

  Then, when you declare the struct or class, insert the word pk next before
every `;' that comes at the end of a member declaration, e.g.:-

typedef struct{long di,si,bp,res,bx,dx,cx,ax pk;
    short flags,es,ds,fs,gs,ip,cs,sp,ss pk;} Regs;
class dirbuf{public:byte Reservebuf[21],attrib pk; FCBtime time pk;
    FCBdate date pk; uns long size pk; char name[13] pk;
    dirbuf();
    byte GetFirst(char*dirname, uns int attrib=~0);
    byte GetNext();
    int get(char*name);};

- Raw text -


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