【问题标题】:Compile Error in using /usr/include/net/if.h使用 /usr/include/net/if.h 时出现编译错误
【发布时间】:2011-10-26 06:23:25
【问题描述】:

我正在尝试为我的 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$ 

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

【问题讨论】:

    标签: macos compilation network-programming libpcap network-security


    【解决方案1】:

    看起来这是包含文件的顺序。请参阅我通过 google 找到的 page

    【讨论】:

    • 在包含其他所有内容后包含 if.h 后工作!非常感谢!
    猜你喜欢
    • 1970-01-01
    • 2014-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-27
    • 2020-09-19
    • 2014-08-29
    • 1970-01-01
    相关资源
    最近更新 更多