Mail Archives: djgpp/1999/08/05/07:46:36
On Thu, 29 Jul 1999 09:53:21 +0200 (MET DST), Wieslaw Bela
<wiechu AT aurora DOT put DOT poznan DOT pl> wrote:
> I want to report a bug that I've found while making a project in
> DJGPP. I don't know where is the problem, but I've tried many
> things, including changing the order of variables, size of arrays, their
> names (I also tried to compile on two different machines), and the effect
> is always the same: the memory for (static) array "wyglad" isn't
> allocated (when I debug it, size of this array is 0), although no bug is
> reported during the make (when I changed the program and allocated
> memory using new operator, everything was OK). I've got the same problem
> with COLOR_MAP structure from allegro, so it seems that DJGPP doesn't
> allocate memory for some structures. Here is a short example of how
> does it work:
>
> const MaxBok = 10, MaxWys = 20;
> const IlWierzch = 4, IlScian = 3;
> struct punkt2D
> {
> int x, y;
> };
> typedef punkt2D sciana [IlWierzch];
>
> sciana wyglad [MaxBok + 1] [MaxBok + 1] [MaxWys + 1] [IlScian];
>
> int main (void)
> {
> return 0;
> }
No bug.
Why should the compiler allocate something for the birds which is not
used in the program ? The program does nothing except returning 0 to
the host environment. For this effect it doesn't need to allocate an
array.
Change your program to
int main ()
{
wyglad[0][0][0][0] = wyglad[0][0][0][1]
return 0;
}
and your 'wyglad' _will_ be allocated.
Regards
Horst
- Raw text -