我在fedora core 5中运行了一个程序(链接是 - http://www.security-freak.net/raw-sockets/sniffer_eth_ip_tcp.c)。在编译时,我收到以下错误:
[root@localhost ~]# gcc sniffer_eth_ip_tcp.c
In file included from sniffer_eth_ip_tcp.c:12: /usr/include/linux/ip.h:97: error: expected specifier-qualifier-list before ‘uint8_t’
In file included from /usr/include/linux/tcp.h:21,
from sniffer_eth_ip_tcp.c:13:
/usr/include/asm/byteorder.h:6:2: warning: #warning using private kernel header; include <endian.h> instead!
sniffer_eth_ip_tcp.c: In function ‘ParseIpHeader’:
sniffer_eth_ip_tcp.c:147: error: ‘struct iphdr’ has no member named ‘daddr’
sniffer_eth_ip_tcp.c:148: error: ‘struct iphdr’ has no member named ‘saddr’
sniffer_eth_ip_tcp.c: In function ‘ParseTcpHeader’:
sniffer_eth_ip_tcp.c:185: error: ‘struct iphdr’ has no member named ‘protocol’
sniffer_eth_ip_tcp.c:187: error: ‘struct iphdr’ has no member named ‘ihl’
但是,相应头文件中的struct iphdr包含上面提到的数据成员。 任何人都可以帮忙..
答案 0 :(得分:3)
获得该错误的唯一方法是,如果您的程序所指的iphdr不包含这些数据成员。因此,搜索所有包含,检查dup等等(同样,您可以通过预编译运行源代码并查找已包含的所有内容,通常会提供您的答案)
[编辑]
在源上运行cpp以找出包含哪些头文件(以哪种顺序)。如果您在正确信息之前包含错误信息的标题,则会出现问题。实质上,只包括编译程序所需的头文件
[/编辑]