j******a 发帖数: 1599 | 1 linux signal的定义。
void (*signal(int signo, void (*func )(int)))(int);
这最后一个int是什么意思阿? 应该是那个function的parameter阿? | t****t 发帖数: 6806 | 2 void (*A)(int): declare A as [pointer to function that takes int as
parameter, with no return]
void (*A(....))(int): declare A as a function that returns [pointer to
function that takes int as parameter, with no return], taking whatever
parameter (...)
replace "..." with "int signo, void (*func)(int)", you get what it means:
declare signal as a function, that returns [pointer to function that takes
int as parameter, with no return], and takes two parameter: first is int,
second is [pointer to function that takes int as parameter, with no return].
The stuff in [] is precisely the protocol of a signal handler. So, declare
signal as a function, that returns pointer to (old) signal handler, and
takes int and pointer to (new) signal handler.
【在 j******a 的大作中提到】 : linux signal的定义。 : void (*signal(int signo, void (*func )(int)))(int); : 这最后一个int是什么意思阿? 应该是那个function的parameter阿?
| j******a 发帖数: 1599 | 3 非常清楚,谢谢大牛。
].
【在 t****t 的大作中提到】 : void (*A)(int): declare A as [pointer to function that takes int as : parameter, with no return] : void (*A(....))(int): declare A as a function that returns [pointer to : function that takes int as parameter, with no return], taking whatever : parameter (...) : replace "..." with "int signo, void (*func)(int)", you get what it means: : declare signal as a function, that returns [pointer to function that takes : int as parameter, with no return], and takes two parameter: first is int, : second is [pointer to function that takes int as parameter, with no return]. : The stuff in [] is precisely the protocol of a signal handler. So, declare
| j*****I 发帖数: 2626 | 4 我觉得如果考虑stack操作会更加容易懂些. 可能外面那个函数的stack还没全退出开,
就进到return的那个函数里面去了。这种操作是不是算是C里面比较tricky的啦?
【在 j******a 的大作中提到】 : 非常清楚,谢谢大牛。 : : ].
| t****t 发帖数: 6806 | 5 what are you talking about...
【在 j*****I 的大作中提到】 : 我觉得如果考虑stack操作会更加容易懂些. 可能外面那个函数的stack还没全退出开, : 就进到return的那个函数里面去了。这种操作是不是算是C里面比较tricky的啦?
| p*********t 发帖数: 2690 | 6 函数名其实就是一个指针。
【在 j******a 的大作中提到】 : linux signal的定义。 : void (*signal(int signo, void (*func )(int)))(int); : 这最后一个int是什么意思阿? 应该是那个function的parameter阿?
| m*******l 发帖数: 12782 | 7 大哥,我说句话,不中听,可能
你的C/C++还需要加强啊.
我上面英语恢复了,好像大家没有看懂.
【在 j*****I 的大作中提到】 : 我觉得如果考虑stack操作会更加容易懂些. 可能外面那个函数的stack还没全退出开, : 就进到return的那个函数里面去了。这种操作是不是算是C里面比较tricky的啦?
|
|