简体   繁体   中英

How to EXCLUDE “winsock2.h”?

I am doing a project on Windows and the "winsock2.h" file is causing issues during compilation (I have an underlying queue library that has function like "send", "receive" etc and it is complaining about the "winsock2.h" also having a "send" function).

I am just including "windows.h", so is there a way I can EXCLUDE the inclusion of "winsock2.h" so that my application can compile?

Thanks for the help ;-)

Lynton

Well, winsock2.h contains an inclusion guard #ifndef _WINSOCK2API_ so defining _WINSOCK2API_ before you include windows.h should prevent it from being included.

Though a better solution, IMO, is to put your library in it's own namespace (eg queue_send, msgq_send, etc.)

If you #define WIN32_LEAN_AND_MEAN before including windows.h, you get a lot fewer headers automatically pulled in.

Though on my system, windows.h includes winsock.h, not winsock2.h, so you may have to double-check it's actually due to including windows.h.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM