> but why does this one need __attribute__ ((packed)) to work well?
No idea, because when I compile with DJGPP (also gcc), I get a size of 10 whether it is packed or not (packed makes no difference). This is what I would expect of a structure where all members have the same size and alignment.
I suggest you first print the sizeof() of this struct when it is packed and unpacked.
> however, all my structs work fine (afaik) except for this one
Perhaps this one is being broken by a previous struct (which should be packed) actually reading too much data.
I suggest you do something like this for each of your structures to make sure they are as you expect
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
typedef struct
{
short xoff, yoff;
short patchnum;
short one, zero;
} /*__attribute__ ((packed))*/ patchentry_t;
int main(void) {
printf( "%d\n", sizeof(patchentry_t) );
printf( "%d\n", offsetof(patchentry_t,xoff) );
printf( "%d\n", offsetof(patchentry_t,yoff) );
printf( "%d\n", offsetof(patchentry_t,patchnum) );
printf( "%d\n", offsetof(patchentry_t,one) );
printf( "%d\n", offsetof(patchentry_t,zero) );
return 0;
}