My program is when i try to compile any modified code i recieve winsock2.h
problems, it says multiple declarations so it seems like its trying to use
this file twice, although before i stored this code it used to complie ok.
I have looked through the code looking for the duplication but think im too
tired to stumble upon a simple solution, maybe xp sp2 is messing it up,
Metro.
> My program is when i try to compile any modified code i recieve
> winsock2.h problems, it says multiple declarations so it seems like
> its trying to use this file twice, although before i stored this code it
> used to complie ok.
Actually, it is more likely that your project is including both winsock.h
and winsock2.h. They do not co-exist together very well.
Gambit
I am running into the same error. Everything worked fine until I installed Indy9 into BCB6. I followed the directions in the Knowledge Base, and it seemed to work until I compiled. Now I'm getting winsock errors. Is there any way to force everything in the project to use the same winsock?
Regan
> I am running into the same error. Everything worked fine until I
installed Indy9 into BCB6.
Indy 9 uses winsock2.h. The native VCL components (and many third-party
socket components in general) still use winsock.h instead.
> Is there any way to force everything in the project to use the same
winsock?
No, because the other components have been coded to use winsock.h instead of
winsock2.h. You can't make winsock.h magically work like winsock2.h does.
Winsock2.h disables winsock.h if winsock2.h is included by the precompiler
first, so everything should be ok in that scenerio. However, if winsock.h
is included by the precompiler first, then winsock2.h produces duplicate
declarations because Microsoft did not write winsock2.h to not redeclare
everything that winsock.h already declares.
Had Microsoft been smart, they would have had winsock2.h simply include
winsock.h and then have winsock2.h declare only the new things that
winsock2.h actually adds that winsock.h does not have. But since when does
Microsoft actually act smart? They took winsock.h, duplicated everything
into winsock2.h, and then had winsock2.h disable winsock.h. Thus winsock2.h
does not work properly when winsock.h is included in a project first. I
suppose they did that thinking that everyone would simply replace all
occurances of winsock.h with winsock2.h and everything would be good, and
they would be right in that regard. But apparently, they did not take into
account what would happen when the two try to co-exist in the same project
together. Then all hell breaks out.
Gambit