Jump to content
  • Advertisement
Sign in to follow this  
Android_s

winsock2.h and windows.h colliding!?

This topic is 5041 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! This has bugged me long enough. It seems winsock2.h and windows.h "collides" with each other. If i include them both i get these type of errors (a LOT more though!) c:\program\microsoft visual studio\vc98\include\winsock2.h(573) : warning C4005: 'SOMAXCONN' : macro redefinition c:\program\microsoft visual studio\vc98\include\winsock.h(533) : see previous definition of 'SOMAXCONN' c:\program\microsoft visual studio\vc98\include\winsock2.h(598) : warning C4005: 'FD_READ' : macro redefinition c:\program\microsoft visual studio\vc98\include\winsock.h(551) : see previous definition of 'FD_READ' c:\program\microsoft visual studio\vc98\include\winsock2.h(601) : warning C4005: 'FD_WRITE' : macro redefinition c:\program\microsoft visual studio\vc98\include\winsock.h(552) : see previous definition of 'FD_WRITE' Now if i skip including winsock2.h i don't get those errors, but rather obious, the actual networking code lying in separate .cpp files won't work...<sighs deeply> Is there some #define or setting i have missed or WHAT am i doing wrong!?

Share this post


Link to post
Share on other sites
Advertisement
Are you defining WIN32_LEAN_AND_MEAN before you include the windows header? If you don't have this define, windows.h will automatically include winsock.h and thus create the duplicate definitions.

Share this post


Link to post
Share on other sites
alternatively if you don't want lean and mean, you can include the winsock2.h before windows.h and that will do it also

Share this post


Link to post
Share on other sites
Ahh, thank you both, it built fine now. I actually had quite some trouble with this...a combination of your suggestions finally did it

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!