cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/12/12:02:28

Message-ID: <8D53104ECD0CD211AF4000A0C9D60AE301571AFB@probe-2.acclaim-euro.net>
From: Shawn Hargreaves <ShawnH AT Probe DOT co DOT uk>
To: djgpp AT delorie DOT com
Subject: Re: EUREKA... note about pcx header
Date: Thu, 12 Aug 1999 10:21:14 +0100
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.0.1460.8)
Reply-To: djgpp AT delorie DOT com

sephiroth writes:
> I always get by this problem by specifically defining a short or a
> long. I think this is good practice.

The size of a short or long isn't any more specific than the
size of an int: these can vary depending on your compiler and
the type of machine you are working with. It is never correct
to make any assumptions about the size of data types, which
is why you should never read block data from a file directly
into a structure. To make your code portable, you need to
read each field as a series of individual bytes, and combine
them into whatever memory layout you want to use (this can
most easily be done by writing helper functions that read
values of 16 bits, 32 bits, etc). For an example of this in
action, take a look at the pcx.c file from Allegro.


	Shawn Hargreaves.

- Raw text -


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