my_functions.h
void * f1 (int * param);
void * f2 (int * param);
void * f3 (int * param);
void b1(int * param);
void b2(int * param);
void b3(int * param);
my_prog.c
#include <my_functions.h>
// Typedef my function pointers
typedef void * (*foo)(int*);
typedef void (*bar)(int*);
// Declare the structure that will contain function pointers
typedef struct _my_struct
{
int tag;
foo f;
bar b;
}my_struct;
// Declare and initialize the array of my_struct
my_struct array[] =
{
{1, f1, b1},
{2, f2, b2},
{3, f3, b3}
};
Compiler says:
warning: initialization from incompatible pointer type
I looked at:
- Function Pointers within structures in C
- Initializing a function pointer in C
- How to initialize array of pointers to functions?
But I still can't see what I missed...
For me, all the types and the functions are known by the time I try to initialize my array.
Can't the init be done outside a function ?
[EDIT] I am on Linux, using an embedded version for arm of GCC 4.9.
{x,fx,bx}