我有以下 typedef
函数原型(prototype):
typedef void (*sa_sigaction_t)(int, siginfo_t *, void *);
我不知道如何使用它。我知道 (int, siginfo_t *, void*)
被 typedef
编辑到 sa_sigaction_t
中。但我将如何使用它?这些都是没有指定变量名的返回类型。
所以我假设我想创建一个变量:sa_sigaction_t handler
。我将如何使用它?语法很困惑。
谢谢,
最佳答案
I understand that (int, siginfo_t , void) is typedef-ed into sa_sigaction_t.
其实没有。 sa_sigaction_t
是一个指向函数的指针,该函数返回 void
并以 (int, siginfo_t *, void *)
作为参数。
如果你有:
void foo(int, siginfo_t*, void*)
{
}
你可以这样做:
sa_sigaction_t fooPtr = &foo;
然后这样调用它:
fooPtr(0,NULL,NULL);
关于c - Typedef 函数语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9701758/