【发布时间】:2012-12-21 13:18:59
【问题描述】:
我无法将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_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 上运行 Ubuntu 12.10。
【问题讨论】:
-
我可能读错了错误输出,但似乎
in.h为您包括in6.h。在这种情况下,您不应该已经有IPV6_DONTFRAG可用吗?通常,您实际上不需要包含特定于系统的标头。 (除非该选项是非标准的。) -
可能提供您为此使用的实际
gcc命令可能是个好主意... -
@millimoose:
IPV6_DONTFRAG未在in.h中定义。我可以用#ifndef IPV6_DONTFRAG #define IPV6_DONTFRAG 62 #endif定义它,但我不确定这是否是一个好的解决方案。 @user1849534:g++ -std=c++0x -Wall -g -pedantic -W -DDEBUG -lresolv
标签: c++ linux ubuntu ipv6 ipv4