C 这两个函数指针声明之间有什么区别?

C 这两个函数指针声明之间有什么区别?,c,pointers,C,Pointers,及 第一个是返回整数指针的常量函数指针数组吗?第一个是只读指针数组(即,您不能将fun[i])更改为接收int和char**并返回int指针的函数 第二个非常类似,只是您可以更改fun[i],但它指向的函数返回指向只读整数的指针 因此,简言之: const int *(* fun[])(int argc, char **argv). 当你问cdecl时,它告诉了你什么?为它们两个都提供“语法错误”。但是GCC并不抱怨……要让cdecl解析它,您需要删除参数名,即使其为“int*(*const-


第一个是返回整数指针的常量函数指针数组吗?

第一个是只读指针数组(即,您不能将
fun[i]
)更改为接收
int
char**
并返回
int
指针的函数

第二个非常类似,只是您可以更改
fun[i]
,但它指向的函数返回指向只读整数的指针

因此,简言之:

const int *(* fun[])(int argc, char **argv).

当你问cdecl时,它告诉了你什么?为它们两个都提供“语法错误”。但是GCC并不抱怨……要让cdecl解析它,您需要删除参数名,即使其为“int*(*const-fun[])(int,char**)”。是否应该
example2
const
const int *(* fun[])(int argc, char **argv).
/* First declaration 
int *(*const fun[])(int argc, char **argv)
*/
int arg1;
char **arg2;
int *example = (*fun[i])(arg1, arg2);
*example = 14; /* OK */
example = &arg1; /* OK */
fun[i] = anoter_function; /* INVALID - fun[] is an array of read-only pointers */

/* Second declaration 
const int *(* fun[])(int argc, char **argv)
*/
const int *example2 = (*fun[i])(arg1, arg2);
fun[i] = another_function; /* OK */
*example2 = 14; /* INVALID - fun[i] returns pointer to read-only value. */
example2 = &arg1; /* OK */