Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.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++ 警告:";IPPROTO_TCP";重新定义的警告:这是以前定义的位置_C++_Linux - Fatal编程技术网

C++ 警告:";IPPROTO_TCP";重新定义的警告:这是以前定义的位置

C++ 警告:";IPPROTO_TCP";重新定义的警告:这是以前定义的位置,c++,linux,C++,Linux,我在编译时收到此警告 In file included from server.c:48: unixwin.h:23:1: warning: "IPPROTO_TCP" redefined In file included from server.c:42: /usr/include/netinet/in.h:45:1: warning: this is the location of the previous definition 以下是错误中引用的部分: 文件unixwin.h 15 16

我在编译时收到此警告

In file included from server.c:48:
unixwin.h:23:1: warning: "IPPROTO_TCP" redefined
In file included from server.c:42:
/usr/include/netinet/in.h:45:1: warning: this is the location of the previous definition
以下是错误中引用的部分:

文件unixwin.h

15
16 #ifndef FALSE
17 #define FALSE 0
18 #endif
19
20 #define SOCKADDR_IN struct sockaddr_in
21 #define SOCKET_ERROR -1
22 #define INVALID_SOCKET (SOCKET)(~0)
23 #define IPPROTO_TCP 6
24 #define LPSOCKADDR struct sockaddr *
25 #define GMEM_MOVEABLE 1
26 #define GMEM_FIXED 2
27 #define GMEM_SHARE 3
28 #define GPTR 4
29 #define LPHOSTENT struct hostent *
30 #define LPIN_ADDR struct in_addr *
31
32 #ifndef UINT
33 #define UINT unsigned int
34 #endif
35
在文件服务器.c中

37
38 #ifdef UNIX
39 #include <sys/types.h>
40 #include <sys/socket.h>
41 #include <sys/ioctl.h>
42 #include <netinet/in.h>
43 #include <arpa/inet.h>
44 #include <time.h>
45 #ifndef FIONREAD
46 #include <sys/filio.h>
47 #endif
48 #include "unixwin.h"
49 #endif
50
你能说出课文哪里错了吗 谢谢 抱歉,这只是文件中出现错误的部分 unixwin.h和server.c是运行时公司提供给我们链接的文件 当前linux glibc版本的运行时,in.h是随附的linux文件 OpenSUSE 11.0 如果你看一下错误和行号,这是我在这里选择和粘贴的。
感谢所有帮助

您正在unixwin.h第23行重新定义IPPROTO_TCP,该宏已从netinet/in.h获得


您只需将netinet/in.h包含在内,无需再次将其定义为6。

您正在unixwin.h第23行重新定义IPPROTO_TCP,该宏已从netinet/in.h中提供

您只需将netinet/in.h包含在内,无需再次将其定义为6。

添加此项

#ifndef IPPROTO_TCP
#define IPPROTO_TCP 6
#endif
在您的文件unixwin.h.

中添加此项

#ifndef IPPROTO_TCP
#define IPPROTO_TCP 6
#endif

在您的文件unixwin.h.

中,您打算如何处理文件“unixwin.h”?它看起来充满了应该来自系统头文件的#定义

我会试着把它去掉

#define IPPROTO_TCP
…并插入

#include <netinet/in.h>
#包括

您打算如何处理文件“unixwin.h”?它看起来充满了应该来自系统头文件的#定义

我会试着把它去掉

#define IPPROTO_TCP
…并插入

#include <netinet/in.h>
#包括

Hum。。。那么您使用的是定义为自身值的宏?这很糟糕…为什么你需要在unixwin.h中重新定义所有这些内容?可能重复“不要问两次问题”,这是一种糟糕的形式:/哼哼。。。那么您使用的是定义为自身值的宏?这很糟糕……为什么你需要在unixwin.h中重新定义所有这些内容?可能重复的“不要问两次问题,这很糟糕”形式:/谢谢这有帮助我认为其他人也会有帮助,但这是最容易做的感谢感谢感谢这有帮助我认为其他人也会有帮助,但这是最容易做的感谢