Hi,
I have written a function which receives a pointer to a two-dimensional array of structs. To use the GNU Scientific Library (which is excellent) I need to wrap the function in another function of form:
void wrapper(void *)
How should I do this? The short but complete example below works but my compiler complains about an incompatible type:
main.c:18: warning: passing argument 1 of 'func' from incompatible pointer type
[refering to the func(z) line in wrapper()]
I think the problem is that "struct coord ** z" and "struct coord z[][]" are not of the same type. What is the right way to do this? The one-dimensional version compiles silently and works perfectly. All comments welcome!
Thanks,
Neil.
Code:#include <stdio.h> struct coord { int x; int y; }; void func(struct coord z[2][2]) { printf("%d,%d\n", z[0][0].x, z[0][0].y); } void wrapper(void * s) { struct coord ** z; z = (struct coord **) s; func(z); } int main(void) { struct coord b[2][2]; void * c; b[0][0].x = 1; b[0][0].y = 2; b[0][1].x = 3; b[0][1].y = 4; b[1][0].x = 5; b[1][0].y = 6; b[1][1].x = 7; b[1][1].y = 8; func(b); c = (void *) b; wrapper(c); return 0; }