C PCAP 库未知类型错误 [英] C PCAP library unknown types error

查看:106
本文介绍了C PCAP 库未知类型错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 linux 系统上安装了 pcap 库,但在包含它时出现错误

I installed the pcap library on my linux system but when including it I get the errors

 /usr/include/pcap/bpf.h:88:1: error: unknown type name ‘u_int’
 /usr/include/pcap/bpf.h:108:2: error: unknown type name ‘u_int’
 /usr/include/pcap/bpf.h:1260:2: error: unknown type name ‘u_short’
 /usr/include/pcap/bpf.h:1261:2: error: unknown type name ‘u_char’
 /usr/include/pcap/bpf.h:1262:2: error: unknown type name ‘u_char’
 In file included from ../src/test.c:1:0:
 /usr/include/pcap/pcap.h:125:2: error: unknown type name ‘u_short’
 /usr/include/pcap/pcap.h:126:2: error: unknown type name ‘u_short’
 /usr/include/pcap/pcap.h:171:2: error: unknown type name ‘u_int’
 ...
 make: *** [src/test.o] Error 1

我包括了

 #include <pcap/pcap.h>
 #include <sys/types.h>
 #include <pcap-bpf.h>

在程序中,我缺少什么?

in the program, what am I missing?

推荐答案

确保您定义以下任何一项:

Make sure you do NOT define any of:

  • __STRICT_ANSI__
  • _ISOC99_SOURCE
  • _POSIX_SOURCE
  • _POSIX_C_SOURCE
  • _XOPEN_SOURCE
  • _SVID_SOURCE

在构建程序时;它们可能会阻止定义 BSD 数据类型,例如编译器抱怨的那些.

when building your program; they may prevent the BSD data types, such as the ones the compile is complaining about, from being defined.

这篇关于C PCAP 库未知类型错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆