This is dumb, but I'm having trouble getting the right type signature or something. I want to have a function return a two-dimensional array (fixed size on one dimension, variable on the other) but I'm doing something wrong. Minimal example:
void useit(unsigned long sz) {
uint32_t arr[sz][8] = makeit(sz);
// Do something useful with arr here
}
// Stub function for allocating and filling an array
uint32_t (*makeit(ulong sz))[8] {
uint32_t (*arr)[8] = malloc(8*sz*sizeof(int));
int i, j;
for (i = 0; i < sz; i++) {
for (j = 0; j < 8; j++) {
arr[i][j] = 10*i+j+11;
}
}
return arr;
}
But I don't have the signature right, because gcc complains:
error: incompatible types when assigning to type 'uint32_t[8]' from type 'uint32_t (*)[8]'