In the following code snippet, what can be done to a) hush the compiler, and b) clean up the eye-crossing pointer mess?
extern struct tree *sintablein[sintablesize];
struct tree *(*tablein)[];
int i;
tablein = &sintablein; // The compiler complains:
// "redundant & applied to array (warning)" and
// "illegal conversion between pointer types (warning)"
for(i = 0; i < 10; i++) {
struct tree *tablemember = (*tablein)[i]; // However, this works like a charm.
// Do stuff with tablemember
}
The only way I was able to get this far was with the very helpful http://cdecl.org/. In particular regarding (b), how can I simplify the pointers and dereferences as much as possible?
I would do it like this:
Note that when you did
(*tablein)[i]you were taking the first element of thetableinarray and treating it as an array ofstruct treeitems instead of a singlestruct tree*pointer. That’s probably not what you intended.