delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/02/22/20:14:31

Sender: nate AT cartsys DOT com
Message-ID: <36D2009E.E256EFBD@cartsys.com>
Date: Mon, 22 Feb 1999 17:13:02 -0800
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.1 i586)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: Help
References: <36D162CB DOT E5B730A6 AT game-master DOT com>
Reply-To: djgpp AT delorie DOT com

Kevin Lang/Ultima wrote:
> 
> Can anyone tell me if what I am doing is right?
> 
> Because I am getting "converting pointer from integer without cast"
> warnings but I don't know what I am doing wrong.

It's helpful if you can post the complete error message, including the
line number and refer it to the appropriate source line.  It's also
better to post short sources, like this one, as plain text instead of
zip.  I had to unzip and feed it to my compiler to reproduce your error
message, and it took a little work as I am on Linux and your source
contains "#ifndef DJGPP / #error".

Now.

For reference, the complete error is:

iso_load.c: In function `load_tile_map':
iso_load.c:47: warning: passing arg 1 of `pack_fread' makes pointer from
integer without a cast

which refers to source line

pack_fread(iso_map->tile_map[((iy<<(iso_map->ysize))+ix)].attributes,sizeof(int),level_data);

(Hope line wrap doesn't screw it up too much.)  Relevant declarations:

typedef struct TILE {
 int attributes; // 32 bits for attributes
 char tile;      // which tile to draw
 char lighting;  // 0-255
 char z;     // z modifies the y axis on a 1:1 ratio
 int unused;
} TILE;

typedef struct ISO_MAP {
 int x,y,z;  // Starting position of player
 char name[32]; // Name of map
 int xsize,ysize; // Size of map.
 int unused1,unused2;
 TILE *tile_map;
} ISO_MAP;

ISO_MAP *iso_map;

The first argument of `pack_fread' is supposed to be `void *', but the
compiler thinks it's an integer.  Let's have a look.

iso_map->tile_map[((iy<<(iso_map->ysize))+ix)].attributes

Actually, it's quite simple.  You can see that TILE.attributes is indeed
an `int', so the compiler is quite justified.

I assume what you want to do is read the contents of the `attributes'
member from the packfile.  `pack_fread' wants its first arg to be a
pointer to the buffer into which to read.  Therefore, all you need to do
is take the address of this horrible expression (with the `&' operator)
and pass that.

HTH
-- 

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


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