有人可以解释一下代码的确切含义吗?像这样执行 typedef 并在函数调用参数中使用“name”是否有效?
typedef uint8 (*Funcptr) (name);
typedef uint8 (*Funcptr1) (name);
typedef struct {
Funcptr func;
Funcptr1 func_1;
} a;
最佳答案
有指向函数的指针,返回一个uint8并在参数中获取名称(可能是其他类型定义,或者如果未定义则无效)
示例:
typedef char * name; /* added to be able to compile */
typedef uint8 (*Funcptr) (name);
uint8 foo(name s)
{
return 0;
}
int main()
{
Funcptr f = &foo;
char bar[] = "bar";
(*f)(bar);
}
关于c - 两个不同函数指针的 typedef 有效吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54442918/