Subject: Re: some warnings when compiling for windows

Re: some warnings when compiling for windows

From: Vincent Torri <vincent.torri_at_gmail.com>
Date: Mon, 31 Oct 2011 14:10:38 +0100

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

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