我一直在尝试将函数指针数组传递给函数。一旦进入该函数,我需要一个指向该函数指针数组的指针,但我不断收到错误消息。当它不是函数参数时,我可以做到这一点。
void (*(*PointerToFuncPtrArray)[2])(unsigned char data[], unsigned char length);
void (*FuncPtr[2])(unsigned char data[], unsigned char length) = {
func1,
func2,
}
void NotArguement(void) // attempt to point to without passing as parameter
{
PointerToFuncPtrArray = &FuncP; // this works
}
// attempt to pass as argument
void AsArguement((void (*ptr[])(unsigned char data[], unsigned char length))
{
PointerToFuncPtrArray = &ptr; // This throws error
}
这抛出...
Error 1 error C2440: '=' : cannot convert from 'void (__cdecl **[])(unsigned char [],unsigned char)' to 'void (__cdecl *(*)[2])(unsigned char [],unsigned char)'