Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple declaration fd_set
#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


Messages In This Thread
Multiple declaration fd_set - by jjeffman - 08-06-2018, 08:16 PM
RE: Multiple declaration fd_set - by rlebeau - 08-06-2018, 09:00 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)