From: Rayne on
Hi all,

I'm sorry, but this is going to be a long post, because I'm trying to
be as detailed as

possible. I'm running the code on Visual Studio .NET 2003. The entire
project has 28

header files, and corresponding .c files where applicable. I'm new to
programming in

Windows, and I'm getting confused with all the different Windows
header files that seem to

be causing these errors. I'm going to split the post into 2 since it
is long.

The 28 self-defined header files (A.h - Z.h, AA.h, BB.txt) are listed
below, showing what

other header files are included. All header files have #include
guards.

A.h
----
#include <WinSock2.h>
#include <Ws2tcpip.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <string.h>
#include <curses.h>
#include <tchar.h>
#include <strsafe.h>

#include "X.h"
#include "AA.h"
#include "R.h"

B.h
----
#include "X.h"
#include "M.h"

C.h
----
#include <WinSock2.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "M.h"

D.h
----
No #includes

E.h
----
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tchar.h>
#include <strsafe.h>

#include "D.h"
#include "R.h"

F.h
----
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

G.h
----
#include <time.h>
#include <curses.h>
#include <pthread.h>
#include <time.h>
#include <pcap.h>

#include "A.h"

H.h
----
#include <WinSock2.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <pcap.h>
#include <string.h>
#include <strsafe.h>
#include <signal.h>

#include "D.h"
#include "U.h"
#include "F.h"
#include "BB.txt"
#include "M.h"
#include "R.h"

I.h
----
#include "V.h"
#include "Y.h"
#include "K.h"
#include "J.h"

J.h
----
#include <stdlib.h>
#include <vector>

#include "X.h"

K.h
----
#include <WinSock2.h>
#include <Ws2tcpip.h>
#include <stdio.h>
#include <string.h>

#include "L.h"
#include "X.h"

L.h
----
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>

M.h
----
#include <WinSock2.h>
#include <ws2tcpip.h>

#include "X.h"

N.h
----
#include <winsock2.h>
#include <windows.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "X.h"
#include "A.h"
#include "P.h"

O.h
----
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <pcap.h>
#include <pthread.h>
#include <strsafe.h>

#include "Z.h"
#include "K.h"

P.h
----
#include <WinSock2.h>
#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <fcntl.h>

#include "X.h"

Q.h
----
#include <stdlib.h>
#include <pthread.h>
#include <vector>
#include <algorithm>

#include "K.h"
#include "V.h"
#include "C.h"
#include "S.h"
#include "I.h"

R.h
----
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <strsafe.h>

S.h
----
#include <stdlib.h>
#include <stdio.h>
#include <windef.h>

T.h
----
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <pcap.h>
#include <signal.h>
#include <strsafe.h>

#include "V.h"
#include "Y.h"
#include "W.h"
#include "Q.h"
#include "N.h"
#include "G.h"
#include "A.h"

U.h
----
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

V.h
----
#include "K.h"
#include "O.h"
#include "B.h"
#include "I.h"
#include "M.h"

W.h
----
#include <stdlib.h>
#include <time.h>
#include <pthread.h>

#include "K.h"
#include "Q.h"

X.h
----
No #includes

Y.h
----
#include "K.h"
#include "O.h"
#include "B.h"
#include "S.h"
#include "I.h"
#include "M.h"

Z.h
----
#include <Windows.h>
#include <time.h>

#include "X.h"

AA.h
-----
#include <WinSock2.h>
#include <WS2tcpip.h>
#include <Windows.h>

BB.txt
-------
No #includes
From: Rayne on
I'm getting mostly redefinition errors that point to Winsock2.h and
WS2tcpip.h. They all refer to "see previous definition if
'<variable>'" in WinSock.h. I'm also getting errors (not redefinition)
that point to WSPiAPi.h, even though this file is not explicitly
#included by me.

There are over a hundred errors, and I'm showing the representative
ones:

error C2011: 'fd_set' : 'struct' type redefinition
error C2011: 'hostent' : 'struct' type redefinition
error C2011: 'ip_mreq' : 'struct' type redefinition
error C2011: 'linger' : 'struct' type redefinition
error C2011: 'timeval' : 'struct' type redefinition
error C2011: 'WSAData' : 'struct' type redefinition
error C2375: 'accept' : redefinition; different linkage
error C2375: 'bind' : redefinition; different linkage
error C2375: 'connect' : redefinition; different linkage
error C2375: 'gethostbyname' : redefinition; different linkage
error C2375: 'gethostname' : redefinition; different linkage
error C2375: 'htonl' : redefinition; different linkage
error C2375: 'inet_addr' : redefinition; different linkage
error C2375: 'inet_ntoa' : redefinition; different linkage
error C2375: 'WSAAsyncGetHostByAddr' : redefinition; different linkage
error C2375: 'WSAStartup' : redefinition; different linkage

error C2440: '=' : cannot convert from 'char *(__stdcall *)(in_addr)'
to 'char *'
error C2440: '=' : cannot convert from 'char *(__stdcall *)(in_addr)'
to 'char *' There is no context in which this conversion is possible
error C2440: '=' : cannot convert from 'hostent *(__stdcall *)(const
char *)' to 'hostent *'
error C2440: '=' : cannot convert from 'hostent *(__stdcall *)(const
char *)' to 'hostent *' There is no context in which this conversion
is possible
error C2440: '=' : cannot convert from 'servent *(__stdcall *)(const
char *,const char *)' to 'servent *'
error C2440: '=' : cannot convert from 'servent *(__stdcall *)(const
char *,const char *)' to 'servent *' There is no context in which this
conversion is possible
error C2440: '=' : cannot convert from 'u_long (__stdcall *)(u_long)'
to 'DWORD'
error C2440: '=' : cannot convert from 'u_long (__stdcall *)(u_long)'
to 'DWORD' This conversion requires a reinterpret_cast, a C-style cast
or function-style cast
error C2450: switch expression of type 'int (__stdcall *)(void *) is
illegal Integral expression required
error C3861: 'gethostbyaddr': identifier not found, even with argument-
dependent lookup
error C3861: 'getservbyname': identifier not found, even with argument-
dependent lookup
error C3861: 'htonl': identifier not found, even with argument-
dependent lookup
error C3861: 'htons': identifier not found, even with argument-
dependent lookup
error C3861: 'inet_ntoa': identifier not found, even with argument-
dependent lookup
error C3861: 'inet_addr': identifier not found, even with argument-
dependent lookup
error C3861: 'ntohs': identifier not found, even with argument-
dependent lookup
error C3861: 'WSAGetLastError': identifier not found, even with
argument-dependent lookup

warning C4005: 'AF_IPX' : macro redefinition
warning C4005: 'AF_MAX' : macro redefinition
warning C4005: 'FD_ACCEPT' : macro redefinition
warning C4005: 'FD_CONNECT : macro redefinition
warning C4005: 'IP_ADD_MEMBERSHIP' : macro redefinition
warning C4005: 'IP_DROP_MEMBERSHIP' : macro redefinition
warning C4005: 'IP_TOS' : macro redefinition
warning C4005: 'SO_DONTLINGER' : macro redefinition
warning C4005: 'SOMAXCONN' : macro redefinition

I don't know why I'm getting these errors, and I would greatly
appreciate any help I can get.

Thank you!

Regards,
Rayne
From: Alf P. Steinbach on
* Rayne:
> I'm getting mostly redefinition errors that point to Winsock2.h and
> WS2tcpip.h. They all refer to "see previous definition if
> '<variable>'" in WinSock.h. I'm also getting errors (not redefinition)
> that point to WSPiAPi.h, even though this file is not explicitly
> #included by me.
>
> There are over a hundred errors, and I'm showing the representative
> ones:
>
> error C2011: 'fd_set' : 'struct' type redefinition

Try to include <windows.h> before anything else.

Everywhere you use any Windows API stuff.


Cheers & hth.,

- Alf
From: Rayne on
I added the Command Line Option /D_WINSOCKAPI_ and can now compile and
run the program.

Thank you for all your help!
From: Rayne on
I added the Command Line Option /D_WINSOCKAPI_ and can now compile and
run the program.

Thank you for all your help!