I’m trying to create a Macro function for defining function pointers , functions etc.
Here’s what I’m trying to do:
#define PRO_SIGNAL_MAX 5
#define PRO_SIGNAL( func, param ) (*func [ PRO_SIGNAL_MAX ])(param)
I want to use this to declare an array of function pointers of size PRO_SIGNAL_MAX.
So, when I use this here:
void PRO_SIGNAL( paint, (Pro_Window*) );
I want it to generate:
void (*paint [ 5 ])(Pro_Window*) ;
but it isn’t working quite as I planned, I get this error:
pro_window.c|16|error: expected declaration specifiers or '...' before '(' token|
What exactly is the problem?
Omit the parentheses around
Pro_Window*:Macro parameters are substituted literally, so you ended up with:
which is a syntax error.
Also, it is a good practice to enclose macro parameters in parentheses in the macro itself, since you never know whether the caller will pass an expression or a single token: