delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/15/11:49:33

Xref: news2.mv.net comp.os.msdos.djgpp:5916
From: brucef AT central DOT co DOT nz (Bruce Foley)
Newsgroups: comp.os.msdos.djgpp
Subject: packed attribute ?
Date: Fri, 12 Jul 1996 11:04:28 GMT
Organization: Internet Company of New Zealand
Lines: 37
Message-ID: <4s5env$cqi@status.gen.nz>
NNTP-Posting-Host: brucef.central.co.nz
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi.  just a quick question regarding the __attribute__ ((packed))
clause commonly used on data structures.

Can someone confirm exactly what this implies, or perhaps
more importantly, what the absence of it implies.
For example, I see it is required when accessing VBE based
data structures, and I imagine that if the packed clause was not
used then the data structure would be mis-aligned with what
vesa has returned.  Does this mean then, that DJGPP will
align data on word or even dword boundaries?
for example, how would you address next_byte if you
were writing an assembler module and had the
starting address of the below structure.  If it was
packed, then it would be at offset 1, but what if the
packed clause wasn't used?  This is not something
I have encountered in real-mode programming.

typedef struct
{
char	byte_at_offset_0;	// Offset 0
char	next_byte;	// Offset ?
} DEMO_STRUCT;

DEMO_STRUCT MyData;


Also, I notice that assmbler code is often
preceded with .align 4.

I imagine this is to force the start of code to be aligned
on a dword boundary.  Is this purely a performance
concession?

Regards, Bruce.



- Raw text -


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