Page 1 of 1

Multiple declaration for 'fd_set' in winsock2- Builder C++ 5

Posted: Wed 22 Sep 2010 08:29
by tkujalow
I'm using ODAC for Builder C++ 5 since about 4 years in my server application. After upgrade from 6.50.0.39 to 7.xx I got error: " [C++ Error] winsock2.h(103): E2238 Multiple declaration for 'fd_set' [C++ Error] winsock.h(55): E2344 Earlier declaration of 'fd_set' ". I checked some previous versions and I found that this error began with wersion 6.90.0.54. Version 6.90.0.53 is ok, but 6.90.0.54 not.

Could you explain what is wrong with this new verstions of ODAC (since 6.90.0.54).

1) Compiler Errors:

[C++ Error] winsock2.h(103): E2238 Multiple declaration for 'fd_set'
[C++ Error] winsock.h(55): E2344 Earlier declaration of 'fd_set'
[C++ Error] winsock2.h(106): E2146 Need an identifier to declare
[C++ Error] winsock2.h(147): E2238 Multiple declaration for 'timeval'
[C++ Error] winsock.h(98): E2344 Earlier declaration of 'timeval'
[C++ Error] winsock2.h(203): E2238 Multiple declaration for 'hostent'
[C++ Error] winsock.h(154): E2344 Earlier declaration of 'hostent'
[C++ Error] winsock2.h(216): E2238 Multiple declaration for 'netent'
[C++ Error] winsock.h(167): E2344 Earlier declaration of 'netent'
[C++ Error] winsock2.h(223): E2238 Multiple declaration for 'servent'
[C++ Error] winsock.h(174): E2344 Earlier declaration of 'servent'
[C++ Error] winsock2.h(235): E2238 Multiple declaration for 'protoent'
[C++ Error] winsock.h(186): E2344 Earlier declaration of 'protoent'
[C++ Error] winsock2.h(319): E2238 Multiple declaration for 'in_addr'
[C++ Error] winsock.h(270): E2344 Earlier declaration of 'in_addr'
[C++ Error] winsock2.h(377): E2238 Multiple declaration for 'sockaddr_in'
[C++ Error] winsock.h(320): E2344 Earlier declaration of 'sockaddr_in'
[C++ Error] winsock2.h(387): E2238 Multiple declaration for 'WSAData'
[C++ Error] winsock.h(330): E2344 Earlier declaration of 'WSAData'
[C++ Error] winsock2.h(403): E2146 Need an identifier to declare
[C++ Error] winsock2.h(536): E2238 Multiple declaration for 'sockaddr'
[C++ Error] winsock.h(493): E2344 Earlier declaration of 'sockaddr'
[C++ Error] winsock2.h(545): E2238 Multiple declaration for 'sockproto'
[C++ Error] winsock.h(502): E2344 Earlier declaration of 'sockproto'
[C++ Error] winsock2.h(584): E2238 Multiple declaration for 'linger'
[C++ Error] winsock2.h(584): E2228 Too many error or warning messages
....

2) Compiler shows it in this place:

Winsock2.h

.....

typedef struct fd_set {
u_int fd_count; /* how many are SET? */
SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
} fd_set;

extern int PASCAL FAR __WSAFDIsSet(SOCKET, fd_set FAR *);
.....

Posted: Wed 22 Sep 2010 12:48
by AlexP
Hello,

I could not reproduce the problem.
Please download the latest ODAC version (7.00.0.1) and try again.
If the problem persists, please contact me.

Posted: Wed 22 Sep 2010 13:14
by tkujalow
In ODAC version (7.00.0.1) is the same.
I tested:
7.00.0.1 - WRONG
6.90.0.60 - WRONG
6.90.0.56 - WRONG
6.90.0.55 - WRONG
6.90.0.54 - WRONG
6.90.0.53 - OK
6.90.0.51 - OK
6.50.0.39 - OK

I can test other versions if you want.

Posted: Thu 23 Sep 2010 07:06
by AlexP
Hello,

A similar problem was discussed on http://www.devart.com/forums/viewtopic. ... ight=e2238, please see this thread. If it doesn't help please send me a complete small sample to alexp*devart*com to demonstrate this problem.

Posted: Mon 27 Sep 2010 07:22
by tkujalow
It helped:
replace in DBMonitorMessages.hpp the following line:
Code:
#include <WinSock.hpp>
with
Code:
#include <WinSock2.h>

(WinSock.hpp=>WinSock2.h)

Is it replaced in new versions of dbmonitor, or I have remember about this bug, and always change this line ?

Posted: Mon 27 Sep 2010 08:09
by AlexP
Hello,

This is not a bug. CBuilder 5 works with WinSock by default, however some third-party components require WinSock2. If your application uses such components, you should manually replace WinSock with WinSock2 every time.

Posted: Mon 27 Sep 2010 08:31
by tkujalow
OK, but I never used DBMoniotor, so why ODAC components use this hpp file. It is very strange. I look up any link to this declaration file, but there's nothing. How can I remove this reference to dbmonitor include file in my application?

Posted: Mon 27 Sep 2010 09:36
by AlexP
Hello,

The TDBMonitor class class is used in the ODAC components, so even if you don't use DBMonitor in your application, the ODAC components need this file for correct work.