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 typeint**; it is of typeint[6][2].search_positionsis not a pointer; it is an array.A pointer to
search_positions[current_orientation], would be of typeint(*)[6][2]if you take the address of the array: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: