here is the code:
typedef struct {
void (*drawFunc) ( void* );
} glesContext;
void glesRegisterDrawFunction(glesContext *glesContext, void(drawFunc*)(glesContext*));
For that last line, i get the error message: "Expected ')' before '*' token"
why?
You have the correct way of doing a function pointer in your struct
(so kudos for that, so many people get it wrong).
Yet you've swapped around the drawFunc
and *
in your function definition, which is one reason why the compiler is complaining. The other reason is that you have the same identifier being used as the type and the variable. You should choose different identifiers for the two different things.
Use this instead:
void glesRegisterDrawFunction(glesContext *cntxt, void(*drawFunc)(glesContext*));
^^^^^^^^^
note here
One solution is to add a pointer to function typedef as follows:
typedef struct {
void (*drawFunc) ( void* );
} glesContext;
// define a pointer to function typedef
typedef void (*DRAW_FUNC)(glesContext*);
// now use this typedef to create the function declaration
void glesRegisterDrawFunction(glesContext *glesContext, DRAW_FUNC func);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With