Mail Archives: djgpp/1996/06/26/00:04:50
Reply to message 9357587 from MATRIX AT IONSYS on 06/24/96 3:34AM
>Sorry to bother everyone with this, but I've been getting some wierd
>numbers from the following programme. It's supposed to read the
>header from a pcx file and tell me about it. The first 4 values from
>the header come through ok (ID, version, encoding, bitdepth), but the
>next 4 (Xmin, Ymin, Xmax, Ymax) are way off. The last time I ran the
>executable, I got the following:
Every time a question like this has come up, it's because a user doesn't
understand the fact that DJGPP is a 32-bit compiler, not a 16-bit compiler,
and aligns all struct members on 4-byte boundaries. Go look in the gcc
docs for the __attribute__ keyword and how it is used, specifically with
the ((packed)) attribute.
If you don't want to bother reading all that, the way to fix your problem
is to change your struct definition as follows:
typedef struct {
....
} __attribute__((packed)) pcxHead;
John
- Raw text -