I have a function that produces several messages which are implemented as different structs. The only thing the messages have in common is a member called 'type' to indicate which type of message it is. The function therefore returns an array of pointers to void. Pointers to void because the array needs to containt pointers to different struct types.
After running the function, I need to dereference the pointers to void. Since I cannot dereference a pointer to void, I need to cast it. But to what type? I read somewhere that I need a switch statement to go through all types and find out what type it is. But then again, how do I know if I have cast the pointer to void to the original type.
QUESTION: Suppose I have a pointer to void that points to a struct. I do know the collection of possible struct's, but I do not know what struct the pointer exactly refers to. Is there a way to find this out?