Can a function return a pointer to an array of variable length arrays?

时间:2016-02-03 03:10:04

标签: c c99

I tried to define the transpose of a square matrix but I'm hung up on the function's type signature. I'm trying to generalize from this (which works):

float (*matrix_transpose (float matrix[4][4]))[4];

To this (which doesn't):

float (*matrix_transpose (int n, float matrix[n][n]))[n];

GCC says this:

error: 'n' undeclared here (not in a function)
 float (*matrix_transpose (int n, float matrix[n][n]))[n];
                                                       ^

Is there a correct way or write what I want or is it perhaps not possible in the language, or a standards oversight, or a GCC bug?

0 个答案:

没有答案