Hi everyone, this is unidef

Richard Biener richard.guenther@gmail.com
Mon Jul 8 16:34:00 GMT 2019


On Mon, Jul 8, 2019 at 5:29 PM Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>
> On Mon, 8 Jul 2019 at 14:53, Unidef <unidef@unidef.org> wrote:
> >
> > Is it possible to have c or c++ natively have multi dimensional arrays? Instead of using some bourgeois macro function?
>
> This doesn't seem like a question about GCC development, so is
> off-topic on this mailing list.
>
> If you want to know if it's possible with GCC, then you should use the
> gcc-help list. If you want to know if it's possible in C or C++
> generally, then you should use some other forum dedicated to C and/or
> C++.
>
> They do support multidimensional arrays already, but I assume you mean
> so you can access them like arr[1,2,3] rather than arr[1][2][3]. The
> language grammar doesn't currently allow that, because or the meaning
> of the comma operator, but it might be possible one day in C++, see
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1161r2.html
> for a proposed step in that direction.

For C there's also the possibility to use VLAs like

int index_at (int *p, int n, int m, int i, int j)
{
  return (*(int (*)[n][m])p)[i][j]; // index [i][j] off int[m][n]
}


> Please take replies to a more appropriate forum.



More information about the Gcc-help mailing list