我很难理解sigaction()工作方式.
在<signal.h>,sigaction被定义为
int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
Run Code Online (Sandbox Code Playgroud)
但sigaction也被定义bits/sigaction.h为一种结构.我在这里很困惑,C中的结构可以调用吗?
有人可以给我一个简短的解释吗?
调用该函数,调用sigaction该结构struct sigaction.函数和结构存在于C中的不同命名空间中.它类似于您可以这样做的方式:
#include <stdio.h>
struct x {
int x;
};
static int
x(struct x *x) {
return x->x;
}
int
main(void) {
struct x y;
/* But not "struct x x" as we want to call the "x" function below. */
y.x = 1;
printf("%d\n", x(&y));
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编译器可以x根据各种命名空间来排序.但是这个例子相当过分,如果你在现实生活中做过类似的事情会让你看起来很脏.
| 归档时间: |
|
| 查看次数: |
667 次 |
| 最近记录: |