Mail Archives: djgpp/1995/01/28/02:02:28
>   struct {
>      char name[8];
>      long unused1;
>      word width;
>      word height;
>      long unused2;
>      word p_size;
>   } header;
>
>   fread(&header, sizeof(header), 1, fp);
>
>Then, I put in a debugging line like:
>
>   printf("%d\n", sizeof(header));
>
>Which gave me 24 for output.  If you look carefully, however, you will see 
>that it should be 22.  Why is it giving be 24?  Have no clue, but it must 
>be a bug.  I actually checked the sizeof() of each field in the header 
I am afraid that the bug is in *your* program.  You are depending upon the
non-portable behavior of the structure being packed.  As you have found out,
gcc pads it.  There might be some compiler switch to force the compiler to
pack the structure but I would not rely on it.  You are better off rewriting
parts of your program to remove such non-portable code.  While you are at
it, you should also worry about byte ordering.  Not all systems have the
same byte ordering as the pc.
- Raw text -