Mail Archives: djgpp/1995/11/29/16:12:22

Date: Wed, 29 Nov 1995 22:00:59 +0300
From: "Alexander V. Lukyanov" <lav AT video DOT yars DOT free DOT net>
To: djgpp AT sun DOT soe DOT clarkson DOT edu, mewesolo AT freenet DOT calgary DOT ab DOT ca
Subject: Re: Declaring arrays inside generic function

> From: "Michael E. Wesolowski" <mewesolo AT freenet DOT calgary DOT ab DOT ca>
> Date: Mon, 27 Nov 1995 20:37:32 -0700
> I have a generic function which has as one of its input parameters an int
> which identifies an array size. Within the function, I attempt to declare
> an array of int's:
> int item_count [array_size];
> where array_size is the input parameter. When I look at the array in the
> debugger (gdb) however, what i see is an array of int pointers (I think)
> - something like int (*) [60000] (the 60000 is approximate). If I
> explicitly declare the array as, for example, item_count [10], I get the
> expected array of 10, uninitialized ints. SO, what's the problem?
Surely, dynamic size arrays is very useful extension of C.
It implemented (I think) via ``alloca'' builtin. So, declaring
such an array equivalent to declaring a pointer and initializing
it to alloca(array_size*sizeof(int)).

And finally, int (*) [60000] meens 'pointer to array sized 60000' and
not 'array of pointers'.

BTW, there is no problems with that.

- Raw text -

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