More or less:
struct myStruct { struct myStruct (*myPointer)(int (*foo)(void *)); }; typedef struct myStruct myStruct;
c.myPointer should be fine, but you need to return a copy of the structure, not a pointer to the current local variable c .
struct myStruct { struct myStruct (*myPointer)(int (*foo)(void *)); }; typedef struct myStruct myStruct; struct myStruct myFunction(int (*foo) (void *)) { myStruct c; c.myPointer = foo; return c; }
This compiles, but the compiler (reasonably) complains that foo not exactly the right type. So the problem is that this is the correct type for the function pointer in the structure? And it depends on what you want.
source share