I want to create a task struct containing a function pointer to a callback to execute said task. The task contains the parameters so I would like to pass a "this/self" pointer of the struct to the callback executor function.
This creates circular dependencies and I've been digging around trying various forward declarations etc but can't seem to get it right. Am I missing something that makes this impossible, or is it just that my C syntax wizardry is horribly weak. Changing the task* to a void* seems like cheating?
in task.h :
// create a function pointer type signature for executing a task
typedef int (*executor) (task* self);
// create a task type
typedef struct {
executor exec; // the callback to execute the task
... // various data for the task
} task;