This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: maximum number of dimensions in C/C++ array
- From: Brian Dessent <brian at dessent dot net>
- To: gcc-help at gcc dot gnu dot org
- Date: Sun, 14 May 2006 14:27:25 -0700
- Subject: Re: maximum number of dimensions in C/C++ array
- References: <200605142309.46799.andre.maute@gmx.de>
- Reply-to: gcc-help at gcc dot gnu dot org
andre maute wrote:
> Has somebody an idea where to find the maximum number
> of dimensions for declaring an array?
> How many are supported within GCC and how many are
> mandated by the standards?
>
> e.g.
>
> double v[n1][n2][n3];
> declares obviously a 3-dimensional array of doubles.
The problem is that declaring an array that way causes it to be
allocated on the stack, and the stack is not a good place to allocate
large amounts of memory. You will almost certainly overflow the stack
trying to do this. If instead you use malloc() and pointers, you can
allocate arrays to any arbitrary depth, bounded only by total available
memory.
Brian