Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 不能包括;linux/in6.h“;在Ubuntu 12.10上没有错误_C++_Linux_Ubuntu_Ipv6_Ipv4 - Fatal编程技术网

C++ 不能包括;linux/in6.h“;在Ubuntu 12.10上没有错误

C++ 不能包括;linux/in6.h“;在Ubuntu 12.10上没有错误,c++,linux,ubuntu,ipv6,ipv4,C++,Linux,Ubuntu,Ipv6,Ipv4,如果没有这些重新定义错误,我无法将linux/in6.h头包含到源代码中: In file included from mypmtud.cc:30:0: /usr/include/linux/in6.h:30:8: error: redefinition of ‘struct in6_addr’ In file included from /usr/include/netdb.h:28:0, from mypmtud.cc:23: /usr/include/netine

如果没有这些重新定义错误,我无法将
linux/in6.h
头包含到源代码中:

In file included from mypmtud.cc:30:0: /usr/include/linux/in6.h:30:8: error: redefinition of ‘struct in6_addr’ In file included from /usr/include/netdb.h:28:0,
             from mypmtud.cc:23: /usr/include/netinet/in.h:198:8: error: previous definition of ‘struct in6_addr’ In file included from mypmtud.cc:30:0: /usr/include/linux/in6.h:46:8: error: redefinition of ‘struct sockaddr_in6’ In file included from /usr/include/netdb.h:28:0,
             from mypmtud.cc:23: /usr/include/netinet/in.h:239:8: error: previous definition of ‘struct sockaddr_in6’ In file included from mypmtud.cc:30:0: /usr/include/linux/in6.h:54:8: error: redefinition of ‘struct ipv6_mreq’ In file included from /usr/include/netdb.h:28:0,
             from mypmtud.cc:23: /usr/include/netinet/in.h:275:8: error: previous definition of ‘struct ipv6_mreq’ make: *** [mypmtud] Error 1
如何将
linux/in6.h
文件包含到代码中?我需要
linux/in6.h
用于
IPV6\u DONTFRAG
定义和
setsockopt()
来理解此选项。 我包含的所有其他头文件:

#include <iostream>
#include <fstream>
#include <string>

#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/uio.h>

#include <sstream>
#include <ctype.h>
#include <signal.h>
#include <map>
#include <errno.h>

#include <sys/time.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括

我正在VirtualBox 4.2.6上运行Ubuntu12.10。

看起来像是
linux/in6.h
netdb.h
有名称冲突。如果您可以发现您需要的
netdb.h
中的所有名称都在
linux/in6.h
中,那么您可以删除这些名称,这样就可以了。另外,再次阅读它让我觉得它可能已经包含在你的
netinet/in.h
中了

编辑

(来自下面的评论:)
让我为您分析一下错误消息:
/usr/include/linux/in6.h:30:8:错误:在/usr/include/netdb.h:28:0中包含的文件中重新定义“struct in6_addr”,即netdb.h中已经定义了“struct in6_addr”。Next
netinet/in.h
还提供了导致另一个冲突的结构。之后的一切都是关于在试图包含
netinet/in.h
的同时,在
netinet/in.h
和netdb.h中都定义了一个结构。使用
netdb.h
linux/in6.h
的代码部分是分开的吗?如果是,请尝试不同的文件。我认为,对于不同的文件,您可能遇到的任何冲突都将被消除,因为每个文件都有一种名称空间(我在python上下文中考虑名称空间)。我不是100%确定,但我稍后会检查。

我可能读错了错误输出,但对您来说,
in.h
includes
in6.h
。在这种情况下,您不应该已经有了可用的
IPV6\u DONTFRAG
?通常,您不应该真正需要包含系统特定的头。(除非该选项是非标准的。)可能提供您为此使用的实际
gcc
命令是个好主意…@millimoose:
IPV6\u DONTFRAG
未在
in.h
中定义。我可以用
#ifndef IPV6_DONTFRAG#define IPV6_DONTFRAG 62#endif
来定义它,但我不确定这是否是一个好的解决方案@user1849534:
g++-std=c++0x-Wall-g-pedantic-W-DDEBUG-lresolv
我无法删除
netdb.h
,因为它包含比
linux/in6.h
更多的定义和函数。如果我自己没有定义IPV6,也没有包含linux/in6.h,我得到的是未在此范围内定义的IPV6。让我为您分析一下错误消息:
/usr/include/linux/in6.h:30:8:错误:重新定义/usr/include/netdb.h:28:0中包含的文件中的“struct in6\u addr”in6_addr'已在
netdb.h
中定义。Next
netinet/in.h
还提供了导致另一个冲突的结构。这之后的一切都是关于在试图包含
netinet/in.h
的同时,在
netinet/in.h
netdb.h
中都定义了一个结构。使用
netdb
linux/in6
的代码部分是分开的吗?如果是,请尝试不同的文件。我将用更多的内容编辑我的评论。