Is there an easy explanation for what this error means?
request for member '*******' in something not a structure or union
I’ve encountered it several times in the time that I’ve been learning C, but I haven’t got a clue as to what it means.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It also happens if you’re trying to access an instance when you have a pointer, and vice versa:
As pointed out in a comment, this can be made excruciating if someone goes and
typedefs a pointer, i.e. includes the*in a typedef, like so:Because then you get code that looks like it’s dealing with instances, when in fact it’s dealing with pointers:
Note how the above looks as if it should be written
a_foo.field, but that would fail sinceFoois a pointer to struct. I strongly recommend againsttypedef:ed pointers in C. Pointers are important, don’t hide your asterisks. Let them shine.