www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/26/00:04:50

From: j DOT aldrich6 AT genie DOT com
Message-Id: <199606260356.AA228101373@relay1.geis.com>
Date: Wed, 26 Jun 96 03:30:00 UTC 0000
To: djgpp AT delorie DOT com
Mime-Version: 1.0
Subject: Re: Help -- Reading PCX Header

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 -


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