我有一个数组,看起来像这样:void *的函数指针数组转换
void* functions[]; // pointer to functions, each function returns an int and has int parameters A and B
我想丢在下面这段:
int (*F)(int a, int b) = ((CAST HERE) functions)[0];
int result = F(a, b);
我已经尝试过“(INT( *)(int,int))“作为转换,但编译器抱怨我试图使用函数指针作为数组。
编译器是正确的。检查你的括号。 (0); –
可以尝试:'int(* F)(int,int)=(int(*)(int,int))functions [0];' – 4386427
使用typedef ... –