putty源文件在linux环境下编译遇到问题

廖某 2016-02-17 01:57:06
我在putty官网下,下载了putty的源码,但是在编译到时候遇到了问题。
报错信息如下:
../unix/uxnet.c: 在函数‘sk_getxdmdata’中:
../unix/uxnet.c:853: 错误:dereferencing pointer ‘sa’ does break strict-aliasing rules
../unix/uxnet.c:838: 附注:initialized from here
../unix/uxnet.c:858: 错误:dereferencing pointer ‘sin’ does break strict-aliasing rules
../unix/uxnet.c:858: 错误:dereferencing pointer ‘sin’ does break strict-aliasing rules
../unix/uxnet.c:857: 错误:dereferencing pointer ‘sin’ does break strict-aliasing rules
../unix/uxnet.c:857: 错误:dereferencing pointer ‘sin’ does break strict-aliasing rules
../unix/uxnet.c:857: 错误:dereferencing pointer ‘sin’ does break strict-aliasing rules
../unix/uxnet.c:857: 错误:dereferencing pointer ‘sin’ does break strict-aliasing rules
../unix/uxnet.c:839: 附注:initialized from here
../unix/uxnet.c:866: 错误:dereferencing pointer ‘sin6’ does break strict-aliasing rules
../unix/uxnet.c:866: 错误:dereferencing pointer ‘sin6’ does break strict-aliasing rules
../unix/uxnet.c:864: 错误:dereferencing pointer ‘sin6’ does break strict-aliasing rules
../unix/uxnet.c:864: 错误:dereferencing pointer ‘sin6’ does break strict-aliasing rules
../unix/uxnet.c:864: 错误:dereferencing pointer ‘sin6’ does break strict-aliasing rules
../unix/uxnet.c:836: 附注:initialized from here
../unix/uxnet.c: 在函数‘net_select_result’中:
../unix/uxnet.c:293: 错误:dereferencing pointer ‘ss.64’ does break strict-aliasing rules
../unix/uxnet.c:1071: 附注:initialized from here
../unix/uxnet.c:296: 错误:dereferencing pointer ‘sin’ does break strict-aliasing rules
../unix/uxnet.c:295: 附注:initialized from here
../unix/uxnet.c:300: 错误:dereferencing pointer ‘sin6’ does break strict-aliasing rules
../unix/uxnet.c:300: 错误:dereferencing pointer ‘sin6’ does break strict-aliasing rules
../unix/uxnet.c:300: 错误:dereferencing pointer ‘sin6’ does break strict-aliasing rules
../unix/uxnet.c:300: 错误:dereferencing pointer ‘sin6’ does break strict-aliasing rules
../unix/uxnet.c:299: 附注:initialized from here


其中853行的代码为:
switch(sa->sa_family) {
838行的代码为:
struct sockaddr *sa = (struct sockaddr *)&addr;


整体出错的代码如下:
void *sk_getxdmdata(void *sock, int *lenp)
{
Actual_Socket s = (Actual_Socket) sock;
#ifdef NO_IPV6
struct sockaddr_in addr;
#else
struct sockaddr_storage addr;
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&addr;
#endif
struct sockaddr *sa = (struct sockaddr *)&addr;
struct sockaddr_in *sin = (struct sockaddr_in *)&addr;
socklen_t addrlen;
char *buf;
static unsigned int unix_addr = 0xFFFFFFFF;

/*
* We must check that this socket really _is_ an Actual_Socket.
*/
if (s->fn != &tcp_fn_table)
return NULL; /* failure */

addrlen = sizeof(addr);
if (getsockname(s->s, sa, &addrlen) < 0)
return NULL;
switch(sa->sa_family) {
case AF_INET:
*lenp = 6;
buf = snewn(*lenp, char);
PUT_32BIT_MSB_FIRST(buf, ntohl(sin->sin_addr.s_addr));
PUT_16BIT_MSB_FIRST(buf+4, ntohs(sin->sin_port));
break;
#ifndef NO_IPV6
case AF_INET6:
*lenp = 6;
buf = snewn(*lenp, char);
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
memcpy(buf, sin6->sin6_addr.s6_addr + 12, 4);
PUT_16BIT_MSB_FIRST(buf+4, ntohs(sin6->sin6_port));
} else
/* This is stupid, but it's what XLib does. */
memset(buf, 0, 6);
break;
#endif
case AF_UNIX:
*lenp = 6;
buf = snewn(*lenp, char);
PUT_32BIT_MSB_FIRST(buf, unix_addr--);
PUT_16BIT_MSB_FIRST(buf+4, getpid());
break;

/* XXX IPV6 */

default:
return NULL;
}

return buf;
}


我的gcc编译器版本为4.4.7 20120313 (Red Hat 4.4.7-16) (GCC),操作系统为centos6.6
...全文
246 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
廖某 2017-04-17
  • 打赏
  • 举报
回复
我都忘记是怎么解决的了。。。结帖吧。。
假正经的班长 2016-02-17
  • 打赏
  • 举报
回复
http://stackoverflow.com/questions/3464888/dereferencing-pointer-does-break-strict-anti-aliasing-rules-using-berkeley-socke 据说是gcc的bug,解决方法是把诸如 sin->sin_port 的形式改成 (*sin).sin_port

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧