I can do free(STRUCTPOINTER->thing1->thing2)
but I can't do free((*STRUCTPOINTER).(*thing1).thing2)
(Expected identifier before ( token. For (*thing1
nor can I do free((*STRUCTPOINTER).thing1.thing2)
Error, (*temporary)-> is a pointer, did you mean to use '->' ?
I am used to writing my code and referring to things in (*this).format. Is this possible for what I'm trying to do?
CodePudding user response:
As I noted (more or less) in a comment:
If you're insane enough not to use the arrow notation, you would need to use:
free((*(*ptr).thing1).thing2);
I'm sorry, but I don't like shouting as loudly as STRUCTPOINTER
requires, especially as it isn't a macro; I'm using ptr
instead.
*ptr
is the structure thatptr
points to(*ptr).thing1
is the member of the structure, which is a pointer to a structure, so you need*(*ptr).thing1
to dereference the structure, and(*(*ptr).thing1).thing2
to access the element
The arrow notation was invented for a good reason — this is it! It is hard to get the alternative correct.