Issue when declaring functionpointer

I have two functions:
void emptyFunction(int functionChoice)
{
}

void randomizeButtons(Button* array[], u8 items)
{
int counter;
for(counter=0; counter<items; counter++)
{
array[counter]->posX = 220*rand();
array[counter]->posY = 220*rand();

drawButton(array[counter]);
}
}

And two pointers to these functions:
void (*foo)(int);
foo = &emptyFunction;

void (*foo2)(Button*, u8);
foo2 = &randomizeButtons;

The second pointer though, gives a warning:
warning: assignment from incompatible pointer type

To solve this, for the second pointer only, I have to change the function declaration OR typecast to (void*).
So solution 1:
void (*foo2);

And solution 2:
foo2 = (void*) &randomizeButtons;

Very strange, because this isn’t needed for the first functionpointer, foo.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: