www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/12/04:31:05

Date: Wed, 12 Aug 1998 11:30:59 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Cephaler <cephaler AT hotmail DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: pointers and errors make cephaler go crazy
In-Reply-To: <01bdc535$858a16c0$0100007f@scully>
Message-ID: <Pine.SUN.3.91.980812113039.16932C-100000@is>
MIME-Version: 1.0

On 11 Aug 1998, Cephaler wrote:

> still doesn't work, not it's a sigsegv, and rhide is pointing at a
> perfectly legitimate line of code..
> 
> blit(tiles[map[x][y]->tile],screen,0,0,x*32,y*32,32,32)

Please always post the traceback printed when it crashes.

The most probable cause of the crash is that either map[x][y]->tile is
garbled, or tiles[] is garbled or a NULL pointer.

Is map[x][y]->tile really an index?  You didn't tell, but it could be
that map[x][y]->tile is already a pointer to the tile, so you don't
need to index tiles[] with it.

> so I changed it
> 
> blit(tiles[&map[x][y]->tile],screen,0,0,x*32,y*32,32,32)

This will never work.  You are using a pointer (an address of
map[x][y]->tile) as an index into an array.

> typedef struct {
>   unsigned char tile,tag;
> } _tile;

It is usually a bad idea to use names with leading underscores.  ANSI
C says that these names are reserved for the library, so you could get
a conflict.

- Raw text -


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