【发布时间】:2011-06-27 09:39:25
【问题描述】:
虽然包含<signal.h>,但我收到一条错误消息,指出struct sigaction 是一个不完整的类型。
我不知道该怎么处理它。
请帮忙
#include <signal.h>
struct sigaction act;
int main(int argc, char** argv)
{
int depth;
/* validate arguments number*/
if(argc < 2)
{
printf("fatal error: please use arguments <MaxChild> <MaxDepth>\n");
exit(1);
}
/* register the realtime signal handler for sigchld*/
/*173*/
memset(&act,0,sizeof(act));
act.sa_handler = sigproc;
sigaction(SIGCHLD, /* signal number whose action will be changed */
&act, /* new action to do when SIGCHLD arrives*/
NULL); /* old action - not stored */
srand(time(NULL));
depth = rand() % atoi(argv[2]); /* [0 maxDepth]*/
RecursiveFunc(atoi(argv[1]), depth);
return 0;
}
错误信息:
proc.c: In function ‘main’:
proc.c:173:22: error: invalid application of ‘sizeof’ to incomplete type ‘struct sigaction’
proc.c:174:2: error: invalid use of undefined type ‘struct sigaction’
cc1: warnings being treated as errors
proc.c:175:2: error: implicit declaration of function ‘sigaction’
【问题讨论】:
-
这段代码在我的机器上编译。你的编译器是什么?库?编译选项?