I know I can explicitly initialize a 1-d array as follows:
int a1d[] = {0, 1, 2, 3, 4, 5};
This array will have exactly 6 elements - sizeof(a1d) / sizeof(a1d[0])
tells me so.
I'm trying to do this with a 2- (or more) dimensional array:
int a2d[][] = {{0, 1, 2}, {3, 4, 5}};
But gcc errors with error: array type has incomplete element type
.
It would seem that it is explicit from the initialization that this is a 2x3 array, but it would seem this isn't allowed - why is this?
Instead I have to specify all but one dimensions:
int a2d[][3] = {{0, 1, 2}, {3, 4, 5}};
I understand that if I am going to pass an n-dimensional array to a function, then it is absolutely necessary for n-1 dimensions to be specified in the function, as explained by this question Why do we need to specify the column size when passing a 2D array as a parameter?, but it is less obvious to me for the explicitly-initialized case. Is this just a limitation of the standard, or is there a compelling technical reason for this I am missing?