함수에 함수 포인터의 배열을 전달하려고했습니다. 일단 그 함수 포인터의 배열에 포인터가 필요하지만 오류가 계속. 함수 인수가 아닐 때 수행 할 수 있습니다. 함수 인수 목록에서C에서 함수 포인터의 전달 된 배열을 "가리킬"수 없습니다
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)'
오류 메시지가 매우 분명해 보입니다. 'PointerToFuncPtrArray'는 명시적인 크기 정보를 가지고 있습니다; 불완전한 유형 (예 : 누락 된 크기 정보)을 할당하려고합니다. –
타입 변환 문제 외에'AsArgement' 매개 변수 선언에서'()'의 불균형이 생겼습니다. 사실, 컴파일러가 처음보고 할 때의 오류 일 뿐이므로, 그 부분을 간과 해 버리는 것이 궁금합니다. 컴파일하려고하는 실제 코드는 무엇입니까? – AnT