I'm assuming this warning is crashing my app. I'm using objective-c for an iOS app. Xcode doesn't give a stack trace or anything. Not helpful.
I have this assignment as a global variable:
int search_positions[4][6][2] = {{{0,-2},{0,1},{1,-1},{-1,-1},{1,0},{-1,0}}, //UP
{{-2,0},{1,0},{-1,1},{-1,-1},{0,1},{0,-1}}, //LEFT
{{0,2},{0,-1},{1,1},{-1,1},{1,0},{-1,0}}, //DOWN
{{2,0},{-1,0},{1,1},{1,-1},{0,1},{0,-1}} //RIGHT
};
Wouldn't search_positions therefore be a pointer to a pointer to an integer pointer?
Why does this give "Initialisation from incompatible pointer"?
int ** these_search_positions = search_positions[current_orientation];
Surely this just takes a pointer to an integer pointer from the array, offseted by current_orientation?
What I am missing here? I thought I knew pointers by now. :(
Thank you.
search_positions[current_orientation]
is not of type int**
; it is of type int[6][2]
. search_positions
is not a pointer; it is an array.
A pointer to search_positions[current_orientation]
, would be of type int(*)[6][2]
if you take the address of the array:
int (*these_search_positions)[6][2] = &search_positions[current_orientation];
or of type int(*)[2]
if you don't take the address of the array and instead let the array-to-pointer conversion to take place:
int (*these_search_positions)[2] = search_positions[current_orientation];