Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple declaration fd_set
#1
Hello,

I am using Indy 10 (10.6.2.0) on C++Builder 6.0 .

I have built an application which send emails when a certain event happens. It is working fine.

Now I am making a Windows service which should do the same, I am getting include errors telling fd_set has multiple declarations.

I can not figure out why this is happening in the windows service application.

Is there anything I can do to avoid this error?  I have tried to define _winsock2api_ but other errors are being raised when I set it.

Can somebody please help me ?

Best regards,

Jayme Jeffman
Sul Engenharia e Sistemas Ltda
Electrical Energy Supervision and Control
Reply
#2
(08-06-2018, 08:16 PM)jjeffman Wrote: Now I am making a Windows service which should do the same, I am getting include errors telling fd_set has multiple declarations.

Indy uses winsock2.h, but the VCL/Win32 API in BCB6 uses winsock.h instead by default (this was addressed in CB2006 by making windows.h prefer winsock2.h by default).

Those two Winsock header files are NOT compatible with each other!

If winsock2.h is #include'd before winsock.h (the ideal situation), it disables winsock.h and all is OK.

But, if winsock.h is #include'd before winsock2.h (typical, especially in VCL in BCB6), all hell breaks loose, because winsock2.h redeclares many things that winsock.h has already declared (Microsoft designed winsock2.h to *replace* winsock.h, not to *augment* it).

(08-06-2018, 08:16 PM)jjeffman Wrote: Is there anything I can do to avoid this error?

You need to either:

1. make sure winsock2.h is always #include'd before winsock.h. Usually that means adding an #include <winsock2.h> statement before #include <vcl.h> and/or #include <windows.h> statements.

2. add _WINSOCKAPI_ to your project's list of Conditionals to disable winsock.h globally.

3. add WIN32_LEAN_AND_MEAN to your project's list of Conditionals to prevent windows.h from using a #include <winsock.h> statement (amongst others).

(08-06-2018, 08:16 PM)jjeffman Wrote: I have tried to define _winsock2api_ but other errors are being raised when I set it.

That is because you are disabling winsock2.h instead of winsock.h.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)