Subject: Re: some warnings when compiling for windows

Re: some warnings when compiling for windows

From: Alexander Lamaison <swish_at_lammy.co.uk>
Date: Mon, 31 Oct 2011 13:17:12 +0000

On 31 October 2011 13:10, Vincent Torri <vincent.torri_at_gmail.com> wrote:
>
>
> On Mon, Oct 31, 2011 at 1:50 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:
>>
>> On Mon, 31 Oct 2011, Vincent Torri wrote:
>>
>>> Btw, it's just a warning. Also, you ido nclude windows.h:
>>>
>>> in libssh2_priv.h (line  47):
>>>
>>> #include <windows.h>
>>
>> You're right of course and I stand corrected...
>>
>>> so a fix would be (line 47):
>>>
>>> #ifndef WIN32_LEAN_AND_MEAN
>>> # define WIN32_LEAN_AND_MEAN
>>> #endif
>>> #include <windows.h>
>>> #undef WIN32_LEAN_AND_MEAN
>>
>> And this silences the warning nicely I presume?
>
> yes, it does. Note that i looked at Microsoft windows.h header file
> (provided by Visual Studio) some years ago. In it, there is a:
>
> #ifndef WIN32_LEAN_AND_MEAN
> ...
> #include <winsock2.h>
>  ...
> #endif
>
> iirc. So it's normal that it fixes the warning. Here is the patch below (and
> yes, it fixes the warning) :
>
> regards
>
> Vincent Torri
>
> --- ./src/libssh2_priv.h    2011-10-31 13:59:54.000000000 +0100
> +++ ../libssh2-1.3.0_new/src/libssh2_priv.h    2011-10-31 14:03:20.000000000
> +0100
> @@ -44,7 +44,11 @@
>  #include "libssh2_config.h"
>
>  #ifdef HAVE_WINDOWS_H
> +#ifndef WIN32_LEAN_AND_MEAN
> +#define WIN32_LEAN_AND_MEAN
> +#endif
>  #include <windows.h>
> +#undef WIN32_LEAN_AND_MEAN
>  #endif
>
>  #ifdef HAVE_WS2TCPIP_H

Rather than working around this warning, shouldn't the question be why
are we including windows.h rather than the winsock header?

Alex

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-10-31