是否可以创建指向函数指针的指针,即
int32_t (*fp[2])(void) = {test_function1, test_function_2}; // initialize a function pointer
<unknown> = fp;
需要写什么来代替未知?使用“普通”数组,我可以这样做:
int a[2] = {0, 1};
int* p = a;
非常感谢提前。
答案 0 :(得分:20)
typedef void(*func_ptr_t)(void); // a function pointer
func_ptr_t* ptr_to_func_ptr; // a pointer to a function pointer - easy to read
func_ptr_t arr[2]; // an array of function pointers - easy to read
void(**func_ptr_ptr)(void); // a pointer to a function pointer - hard to read
void(*func_ptr_arr [2])(void); // an array of function pointers - hard to read
答案 1 :(得分:2)
typedef int32_t FP(void);
FP *fp[2] = { test_function1, test_function2 };
FP **p = fp;