error: pointer targets in passing argument 3 of 'accept' differ in signedness [-Werror=pointer-sign

代码:

        if((server_fd = accept(sockfd,(struct sockaddr *)&server_addr, &sin_size)) == -1)
        {
            fprintf(stderr, "Accept error:%s\n\a", strerror(errno));
            exit(1);
        }

如果出现下面的情况有两种解决方法:

rfid.c:109:47: error: pointer targets in passing argument 3 of 'accept' differ in signedness [-Werror=pointer-sign]
         if((server_fd = accept(sockfd,(struct sockaddr *)&server_addr, &sin_size)) == -1) 
                                               ^
In file included from rfid.c:22:0:
/opt/buildroot-2012.08/arm920t/usr/arm-unknown-linux-uclibcgnueabi/sysroot/usr/include/sys/socket.h:214:12: note: expected 'socklen_t * __restrict__' but argument is of type 'int *'
 extern int accept (int __fd, __SOCKADDR_ARG __addr,
            ^
cc1: all warnings being treated as errors
make: *** [rfid] 错误 1

第一种:

在makefile文件中注释

#CFLAGS+=-Werror -Wall

第二种:

将代码中sin_size的int类型改为socklen_t

socklen_t   sin_size    =0;
//int     sin_size    = 0;


by fulinux


OK !


参考:

http://www.ajaxstu.com/Linuxbiancheng/294209.html

http://blog.csdn.net/blueliuyun/article/details/7638532



你可能感兴趣的:(网络集合篇,linux函数篇)