gpt4 book ai didi

macos - 使用/usr/include/net/if.h 时编译错误

转载 作者:行者123 更新时间:2023-12-04 06:09:54 25 4
gpt4 key购买 nike

我正在尝试为 Mac Lion 上的网络嗅探器编译现有源代码。我安装了 libpcap。源代码包含一个头文件/usr/include/net/if.h,它会抛出如下所示的编译错误。

Floyd:~ Shastry$ gcc -o arplisten arplisten.c -lpcap
In file included from arplisten.c:4:
/usr/include/net/if.h:265: error: field ‘ifru_addr’ has incomplete type
/usr/include/net/if.h:266: error: field ‘ifru_dstaddr’ has incomplete type
/usr/include/net/if.h:267: error: field ‘ifru_broadaddr’ has incomplete type
/usr/include/net/if.h:308: error: field ‘ifra_addr’ has incomplete type
/usr/include/net/if.h:309: error: field ‘ifra_broadaddr’ has incomplete type
/usr/include/net/if.h:310: error: field ‘ifra_mask’ has incomplete type
/usr/include/net/if.h:393: error: field ‘addr’ has incomplete type
/usr/include/net/if.h:394: error: field ‘dstaddr’ has incomplete type
arplisten.c:6:24: error: netinet/if.h: No such file or directory
arplisten.c: In function ‘main’:
arplisten.c:139: warning: incompatible implicit declaration of built-in function ‘strlen’
Floyd:~ Shastry$

我在谷歌上搜索了很多帮助,但徒劳无功。有人可以帮我解决这个问题吗?

最佳答案

看起来这是包含文件的顺序。看到这个 page ,这是我通过谷歌找到的。

关于macos - 使用/usr/include/net/if.h 时编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7899306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com