C &引用;错误:';结构udphdr';没有名为'的成员;来源'&引用。。。呵呵?
我正在尝试编译一个名为ngrep的程序,当我运行configure时,事情似乎进展顺利,但当我运行make时,我得到:C &引用;错误:';结构udphdr';没有名为'的成员;来源'&引用。。。呵呵?,c,linux,unix,ngrep,C,Linux,Unix,Ngrep,我正在尝试编译一个名为ngrep的程序,当我运行configure时,事情似乎进展顺利,但当我运行make时,我得到: ngrep.c: In function ‘process’: ngrep.c:544: error: ‘struct udphdr’ has no member named ‘source’ ngrep.c:545: error: ‘struct udphdr’ has no member named ‘dest’ make: *** [ngrep.o] Error 1
ngrep.c: In function ‘process’:
ngrep.c:544: error: ‘struct udphdr’ has no member named ‘source’
ngrep.c:545: error: ‘struct udphdr’ has no member named ‘dest’
make: *** [ngrep.o] Error 1
这意味着什么?我该如何修复它?没有早期的警告或错误提示问题的根源。嗯,有一个名为udphdr的结构(可能是udp header的缩写)。程序的某些部分假设该结构具有它没有的成员source和dest 请查看文件ngrep.c第544行和第545行,以查找有问题的行 可能的原因:
- 类型名类型错误
- 结构没有完全定义
- 使用错误的结构
编辑:可能是相关问题:嗯,有一个名为udphdr的结构(可能是udp头的缩写)。程序的某些部分假设该结构具有它没有的成员source和dest 请查看文件ngrep.c第544行和第545行,以查找有问题的行 可能的原因:
- 类型名类型错误
- 结构没有完全定义
- 使用错误的结构
#ifdef HAVE_DUMB_UDPHDR
printf("%s:%d -", inet_ntoa(ip_packet->ip_src), ntohs(udp->source));
printf("> %s:%d", inet_ntoa(ip_packet->ip_dst), ntohs(udp->dest));
#else
printf("%s:%d -", inet_ntoa(ip_packet->ip_src), ntohs(udp->uh_sport));
printf("> %s:%d", inet_ntoa(ip_packet->ip_dst), ntohs(udp->uh_dport));
#endif
显然,configure在这个测试中有一个bug,它认为我的系统有“哑”的udphdr,尽管它没有。将第一行更改为“#if 0”可修复问题。发现问题:
#ifdef HAVE_DUMB_UDPHDR
printf("%s:%d -", inet_ntoa(ip_packet->ip_src), ntohs(udp->source));
printf("> %s:%d", inet_ntoa(ip_packet->ip_dst), ntohs(udp->dest));
#else
printf("%s:%d -", inet_ntoa(ip_packet->ip_src), ntohs(udp->uh_sport));
printf("> %s:%d", inet_ntoa(ip_packet->ip_dst), ntohs(udp->uh_dport));
#endif
显然,configure在这个测试中有一个bug,它认为我的系统有“哑”的udphdr,尽管它没有。将第一行更改为“#if 0”可以解决问题。谢谢你的链接,但我已经安装了build essential,论坛链接到的站点不再存在。谢谢你的链接,但我已经安装了build essential,论坛链接到的站点不再存在。在macOS
ntohs(tcpHeader->source)中
应更改为ntohs(tcpHeader->thu-sport)
和ntohs(tcpHeader->dest)
应更改为ntohs(tcpHeader->thu-dport)
在macOSntohs(tcpHeader->source)
中应更改为ntohs(tcpHeader->-thu-sport)
和ntohs(tcpHeader-dest)
应更改为ntohs(tcpHeader->th\u dport)
。