当添加包括netfilter.h时,我收到错误消息,字段"in","in6"的类型不完整 [英] When add include netfilter.h i got error that fields 'in','in6' has incomplete type

查看:168
本文介绍了当添加包括netfilter.h时,我收到错误消息,字段"in","in6"的类型不完整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具有简单,空的项目,没有任何代码.只是包括. include linux/netfilter.h导致编译错误:

Have simple , empty project without any code. just includes. The include linux/netfilter.h cause to compilation error:

In file included from ../src/main.cpp:2:0:
/usr/include/linux/netfilter.h:65:17: error: field ‘in’ has incomplete type
/usr/include/linux/netfilter.h:66:18: error: field ‘in6’ has incomplete type

您可以在简单的项目中看到,如果删除iostream include,我将有2个include,我将得到其他错误-'/usr/include/linux/sysctl.h:40:2:错误:'size_t'不会命名类型'

As you can see in the simple project i have 2 includes if i remove the iostream include i will get additional error - '/usr/include/linux/sysctl.h:40:2: error: ‘size_t’ does not name a type'

#include <iostream>
#include <linux/netfilter.h>

int main() {
}

如果我在netfilter.h之前添加了netinet/in.h包含项,则没有错误.

if i add include of netinet/in.h before netfilter.h than no errors.

为什么我简单的主程序不能出现这些编译错误?

why my simple main program cannot has these compilation errors?

谢谢

推荐答案

union nf_inet_addr {
    __u32       all[4];
    __be32      ip;
    __be32      ip6[4];
    struct in_addr  in;
    struct in6_addr in6;
};

struct in_addrin6_addr不是完整类型.因此,您应该在netfilter.h

struct in_addr and in6_addr are not complete types. so, you should include header with declaration of structures before netfilter.h

这篇关于当添加包括netfilter.h时,我收到错误消息,字段"in","in6"的类型不完整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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