不能在 Ubuntu 12.10 上包含没有错误的"linux/in6.h"
Can not include "linux/in6.h" without errors on Ubuntu 12.10
我不能包括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
看起来linux/in6.h
与netdb.h
有名称冲突。如果您可以发现netdb.h
中需要的所有名称都在linux/in6.h
中,则可以将其删除,这样就可以了。而且,再读一遍让我觉得它可能已经包含在netinet/in.h
中了。
编辑:
(摘自下面的评论:)让我为您分解错误信息:/usr/include/linux/in6.h:30:8: error: redefinition of ‘struct in6_addr’ In file included from /usr/include/netdb.h:28:0
即。'struct in6_addr'已在netdb.h中定义。接下来netinet/in.h
还提供了导致另一个冲突的结构体。之后的一切都是关于在netinet/in6.h
和netdb.h中先前定义的结构体,同时试图包括netinet/in.h
。使用netdb.h
和linux/in6.h
的代码部分是分开的吗?如果是,请尝试不同的文件。我认为对于不同的文件,您可能拥有的任何冲突都将被删除,因为每个文件都是一种名称空间(我正在考虑python上下文中的名称空间)。我不是百分百确定,但我稍后会检查。
相关文章:
- 在C++/Linux中设置单调时钟的一些技巧
- Linux的Cpp上的计时器
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 在Linux中哪里可以找到互斥、未来等的源代码
- 如何在linux终端中同时编译和运行c++代码
- 在Linux for Windows上编译C++代码时出错
- 如何找到锁定Linux futex的C++行
- 在linux上调试巨大的C++项目
- 如何处理linux终端中带有负号(-)的C++中的命令行参数
- c++方法参数只能在linux的发布模式下自行更改
- 在Linux和C++中的Windows上,散列字符串值会产生不同的输出
- 这里在 Linux 中具有"CreatePipe"和"CreateProcessW"功能吗?
- 函数在Windows或Linux上运行时表现不同
- 在Linux下捕获SIGKILL的C++程序
- 在为LINUX创建共享库时,如何避免STL的私有/弱副本
- 使用 cmake 的 Linux 终端上的"Conversion to non-scalar type is requested"错误
- 如何在CPP中创建应该在Windows和Linux上运行的套接字?
- mysql C++ connector [mysql-connector-c++-8.0.19-linux-glibc2
- 这些是什么样的错误?即使我不在 Linux 上工作,我也遇到了 Linux 错误
- 不能在 Ubuntu 12.10 上包含没有错误的"linux/in6.h"