curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl - Winsock warning problems

From: Ray Satiro via curl-library <curl-library_at_cool.haxx.se>
Date: Tue, 13 Dec 2016 18:50:46 -0500

On 12/13/2016 12:17 PM, Huy Cong Vu wrote:
> when I compile my application, I'm getting a lot of:
>
> warning: #warning Please include winsock2.h before windows.h [-Wcpp]
>
>
> After searching for a while, I found this as a section of curlbuild.h
> in generated build/ folder
>
>
> #defineCURL_PULL_WS2TCPIP_H1
> #ifdefCURL_PULL_WS2TCPIP_H
> #ifndefWIN32_LEAN_AND_MEAN
> #defineWIN32_LEAN_AND_MEAN1
> #endif
> #include<windows.h>
> #include<winsock2.h>
> #include<ws2tcpip.h>
> #endif
>
> However, even if I switch position of windows.h & winsock2.h, the
> problem won't go away. I'm wondering it may be due to another
> declaration of winsock2.h in my application, or I do anything wrong
> with the configuration?

The reason why the problem isn't going away when you switch is because
when WIN32_LEAN_AND_MEAN is defined then windows.h doesn't include
winsock.h, so it doesn't really matter which order they're in there. My
guess is before including curl/curl.h you included windows.h or
something else that includes winsock.h so when curl includes winsock2.h
it gives you the warning. As far as I know we're only including those
headers socklen_t. If you want to get rid of the warning you'll have to
include winsock2.h before any other include that may pull in winsock.h.
There's probably a better solution but at the moment I can't think of
anything.

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-12-14