Re: Indy10 and BCB6: Winsock.h multiple declarations

Giganews Newsgroups
Subject: Re: Indy10 and BCB6: Winsock.h multiple declarations
Posted by:  Remy Lebeau \(Indy Team\) (
Date: Wed, 25 Apr 2007

"Wiebe Vos" <wie…> wrote in message

> However trying to compile my first component - TIdFtp -, I
> get numerous 'multiple decaration' errors for winsock2.h and
> winsock.h.

Indy uses winsock2.h, but the VCL uses winsock.h instead.  winsock.h
and winsock2.h are not compatible with each other.  Instead of having
winsock2.h include winsock.h to pull in common declarations, Microsoft
wrote winsock2.h to redeclare everything fresh (probably so winsock2.h
could completely replace winsock.h), thus the errors when they are
both included in the same unit.  winsock2.h does disable winsock.h,
but only if winsock2.h is included before winsock.h, which can be
tricky as winsock.h can be pulled in by windows.h as well as various
VCL headers.  So you will have to play around with the ordering of
your header includes.  Alternatively, you could try adding
_WINSOCKAPI_ to the Conditionals list in the Project Options so that
winsock.h is completely disabled for the entire application.  But that
might cause other side effects elsewhere.



In response to

Indy10 and BCB6: Winsock.h multiple declarations posted by Wiebe Vos on Wed, 25 Apr 2007