从标准的信号库C的声明 [英] C declaration from standard signal Library

查看:142
本文介绍了从标准的信号库C的声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,有人可以解释这是应该做的:

So can someone explain what this is supposed to do:

void (*signal(int sig, void (*func)(int)) ) (int);

这是标准的信号库中提取的定义。

It is a definition taken from the standard signal library.

推荐答案

启动名为:

signal

往右尽可能您可以:

Go right as far as you can:

signal(int sig, void (*func)(int))

您的参数组合列表,所以它的服用2个参数的函数:一个 INT 名为 SIG 和命名的函数指针 FUNC (你可以分析它在以后的方法相同)。

You have a parenthesized list of parameters, so it's a function taking 2 parameters: an int named sig and a function pointer named func (you can analyze it in the same way later).

然后你打另一个rightparen,让你去左边:

Then you hit another rightparen, so you go left:

*signal(int sig, void (*func)(int))

因此​​函数信号返回一个指针......东西。让我们顺着括号去便又,因为我们可以:

So the function signal returns a pointer to... something. Let's take down the parenthesis and go right again, since we can:

(*signal(int sig, void (*func)(int)) ) (int)

我们再次有带括号的表,所以信号返回一个指针函数,它接受一个 INT 作为独的说法。然后进入又离开了:

We have again a parenthesized list of arguments, so signal returns a pointer to function which takes an int as an only argument. Then go left again:

void (*signal(int sig, void (*func)(int)) ) (int)

这样的功能信号返回函数指针服用 INT 并返回无效

Thus the function signal returns the pointer to function taking int and returning void.

是的,这种语言是怪异,但至少它是一致的。 :)

Yes, this language is weird, but at least it's consistent. :)

这篇关于从标准的信号库C的声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆