Mail Archives: djgpp/1995/01/27/20:48:54
Hi. I've found a major bug that whoever fixes bugs might be interested
in. I've written a map editor for Doom, which I originally wrote to
compile with Borland C++ v3.1. Due to having way to little memory
anymore, I had to do something, so I started porting it to DJGPP.
Luckily, I know someone with experience with porting stuff from Borland to
DJGPP, and he's helped a lot to just get it to compile and run. Now I'm
in the process of fixing up little things that don't quite work. One bug
turned into quite a major bughunt, setting testpoints in half a million
points to track down just what the heck it had at various points along the
way, and recompiling it comstantly and comparing it's results to those
from the Borland C version. But, I have finally found the problem. What
I had was something like this..
typedef short int word;
struct {
char name[8];
long unused1;
word width;
word height;
long unused2;
word p_size;
} header;
fread(&header, sizeof(header), 1, fp);
Then, I put in a debugging line like:
printf("%d\n", sizeof(header));
Which gave me 24 for output. If you look carefully, however, you will see
that it should be 22. Why is it giving be 24? Have no clue, but it must
be a bug. I actually checked the sizeof() of each field in the header
structure, and they all were fine. Add up all six of these sizeof()'s and
you get 22. To fix my code, I just went and changed my old line to:
fread(&header, 22, 1, fp);
Not really the recommented solution, but the only way to get the thing
working again. It works great again with it this way. So, have fun
locating that little bug. :)
-Jason
- Raw text -