当前位置: 代码迷 >> Ruby/Rails >> error: pointer targets in passing argument 三 of 'accept' differ in signedness [-Werror=pointer-sign
  详细解决方案

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

热度:863   发布时间:2016-04-29 02:26:00.0
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 errorsmake: *** [rfid] 错误 1

第一种:

在makefile文件中注释

#CFLAGS+=-Werror -Wall

第二种:

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

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



OK !


参考:

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

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



  相关解决方案