Question 1:
MATRIXP(matrix) m
(matrix
should be a variable of type matrix_t
) will be expanded to
__typeof__(__typeof__(__typeof__(*((matrix).data))[(matrix).cols]) *) m
From in side to out side
__typeof__(*((matrix).data))
is the type of*((matrix).data)
, which isint
according to the definition ofmatrix_t
.so
(__typeof__(*((matrix).data))[(matrix).cols])
equals(int [cols])
so
__typeof__(__typeof__(*((matrix).data))[(matrix).cols]) *)
equals(int [cols] *)
and that is the type given by
MATRIXP(matrix)
.
Therefore, MATRIXP(matrix)
equals (int [(matrix).cols] *)
. In other words,
MATRIXP(matrix) m
is effectively
int (*m)[matrix.cols]
As pointed out by @codebeard
Question 2:
It looks quite safe to me.