I have a struct with a callback function, the callback function needs a pointer to the structure in order to do its operation. How do I properly define these elements such that is will compile without warnings?
typedef struct {
// some fields required for processing...
int (*doAction)(struct pr_PendingResponseItem *pr);
} pr_PendingResponseItem;
If I remove the "struct" attribute on the pr parameter, I get an error. If I leave it in, I get a warning: "its scope is only this definition or declaration, which is probably not what you want"
It all works, but I would like to know the proper way to define such a structure.
Also related, is defining a self referential structure:
typedef struct LinkedItem_ {
LinkedItem_ * prev;
LinkedItem_ * next;
void * data;
} LinkedItem;
(I think this is correct, but additional thoughts are welcome if it is related to the question.)