码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-04-30 22:21:38      阅读:765      评论:0      收藏:0      [点我收藏+]

标签:error   accept   -werrorpointer-sign   socklen_t   #cflags+-werror -wal   

代码:

        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;



OK !


参考:

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

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



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

标签:error   accept   -werrorpointer-sign   socklen_t   #cflags+-werror -wal   

原文地址:http://blog.csdn.net/fulinus/article/details/24796393

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!