红联Linux门户
Linux帮助

程序错误,网上找了很久得不到解决

发布时间:2009-02-23 21:10:35来源:红联作者:blue216
我在编译如下程序时,编译不通过

#include "unistd.h"
#include "stdlib.h"
#include "stdio.h"
#include
#include
#include



int
main(int argc, char **argv)
{
int mqid;
size_t len;
long int type;
struct msgbuf *ptr;

if (argc != 5)
fprintf(stderr,"usage: msgsnd <#bytes> data");
len = atoi(argv[2]);
type = atoi(argv[3]);

mqid = msgget(ftok(argv[1], 0), 0200);

ptr = calloc(sizeof(long) + len, sizeof(char));
ptr->mtype= type; //26行
ptr->mtext=argv[4]; //27行

msgsnd(mqid, ptr, len, 0);

exit(0);
}

总是出现如下错误:


[root@localhost ch6msg]# gcc msgsnd.c -o msgsnd
msgsnd.c: 在函数‘main’中:
msgsnd.c:26: 错误:提领指向不完全类型的指针
msgsnd.c:27: 错误:提领指向不完全类型的指针

哪位高手能不能帮忙解决下
文章评论

共有 2 条评论

  1. blue216 于 2009-02-24 13:36:13发表:

    太感谢了!问题解决了!

  2. deepwhite 于 2009-02-24 12:21:19发表:

    http://topic.csdn.net/t/20041223/11/3669686.html
    have a look