Mail Archives: djgpp/1995/10/04/05:06:42
To djgpp (or more generally GNU users) users,
I saw some time ago on the list that the attribute packed meant that no
word or dword boundary alignment was performed on the argument. So I
wrote the next definitions :
#define PACKED __attribute__ ((packed))
typedef short int int16;
struct TDrive
{ int16 Present PACKED;
char Name[12] PACKED;
};
struct TSetUp
{ char SystemFontName[21] PACKED;
int16 ScreenX,ScreenY PACKED;
int16 ScreenColors PACKED;
int16 DosVer1,DosVer2 PACKED;
TDrive Drives[26] PACKED;
};
The size of TSetUp structure (adding all elements sizes) might be 395 bytes,
but it appears to be 396 1 (in fact a word-boundary alignment is made between
SystemFontName and ScreenX)
Can someone tell me what is the REAL effect of "packed", and what is the good
way to implement a non-aligned structure.
- Raw text -