Compile error: /storage/emulated/0/Android/data/com.cjkj.clanide/files/CJ_IDE/CProject/我的/src/game.c: In function 'play': /storage/emulated/0/Android/data/com.cjkj.clanide/files/CJ_IDE/CProject/我的/src/game.c:31:41: warning: initialization of 'void (*)(int, int *, int *)' from incompatible pointer type 'void (*)(int (*)[10], int *, int *)' [-Wincompatible-pointer-types] void(*prr[4])(int , int*, int*) = { up,down,left,right}; ^~ /storage/emulated/0/Android/data/com.cjkj.clanide/files/CJ_IDE/CProject/我的/src/game.c:31:41: note: (near initialization for 'prr[0]') /storage/emulated/0/Android/data/com.cjkj.clanide/files/CJ_IDE/CProject/我的/src/game.c:31:44: warning: initialization of 'void (*)(int, int *, int *)' from incompatible pointer type 'void (*)(int (*)[10], int *, int *)' [-Wincompatible-pointer-types] void(*prr[4])(int , int*, int*) = { up,down,left,right}; ^~~~ /storage/emulated/0/Android/data/com.cjkj.clanide/files/CJ_IDE/CProject/我的/src/game.c:31:44: note: (near initialization for 'prr[1]') /storage/emulated/0/Android/data/com.cjkj.clanide/files/CJ_IDE/CProject/我的/src/game.c:31:49: warning: initialization of 'void (*)(int, int *, int *)' from incompatible pointer type 'void (*)(int (*)[10], int *, int *)' [-Wincompatible-pointer-types] void(*prr[4])(int , int*, int*) = { up,down,left,right}; ^~~~ /storage/emulated/0/Android/data/com.cjkj.clanide/files/CJ_IDE/CProject/我的/src/game.c:31:49: note: (near initialization for 'prr[2]') /storage/emulated/0/Android/data/com.cjkj.clanide/files/CJ_IDE/CProject/我的/src/game.c:31:54: warning: initialization of 'void (*)(int, int *, int *)' from incompatible pointer type 'void (*)(int (*)[10], int *, int *)' [-Wincompatible-pointer-types] void(*prr[4])(int , int*, int*) = { up,down,left,right}; ^~~~~ /storage/emulated/0/Android/data/com.cjkj.clanide/files/CJ_IDE/CProject/我的/src/game.c:31:54: note: (near initialization for 'prr[3]')
时间: 2023-10-18 08:47:47 浏览: 124
LinkIt_Smart_7688 OpenWrt Linux C or C++ Programming
这个编译警告是因为你尝试将一个接受 `int (*)[10]` 类型参数的函数指针赋值给接受 `int*` 类型参数的函数指针。这两者是不兼容的类型,因此编译器给出了警告。
要解决这个问题,你需要确保函数指针数组 `prr` 的元素类型与函数 `up`、`down`、`left`、`right` 的类型匹配。如果这些函数的参数类型是 `int (*)[10]`,而不是 `int*`,那么你需要相应地更改函数指针数组的声明。
你可以检查一下函数 `up`、`down`、`left`、`right` 的定义,确保它们的参数类型与你所期望的一致。然后,根据实际情况修改函数指针数组的声明,确保类型匹配。这样就可以解决编译警告了。
阅读全文