www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

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 13:47:24 +0100

On Mon, Oct 31, 2011 at 1:34 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Mon, 31 Oct 2011, Ivan Pechorin wrote:
>
> Thanks for this quote. I think it backs up our version.
>
>
> "The Winsock2.h header file internally includes core elements from the
>> Windows.h header file, so there is not usually an #include line for
>> the Windows.h header file in Winsock applications. If an #include line
>> is needed for the Windows.h header file
>>
>
> Note this last 'if'. If windows.h is needed. We don't need it, we don't
> add an include for it...
>
>
> So, as far as I understand, the solution is :
>> 1) either include winsock2.h before windows.h
>> 2) or #define WIN32_LEAN_AND_MEAN, then include windows.h, then
>> include winsock2.h
>>
>
> Right *if* we would want windows.h sure, but why do we have to add it now?
>
> If we haven't had to do it up until now with windows versions of libssh2
> working just fine, why do mingw's new headers suddenly force us to?

Btw, it's just a warning. Also, you ido nclude windows.h:

in libssh2_priv.h (line 47):

#include <windows.h>

later line 95:

#include "libssh2.h"

(which includes winsock2.h)

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

(note that I added a test on WIN32_LEAN_AND_MEAN because some stupid public
headers define it, but do not undef it. I experienced that)
regards

Vincent Torri

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

the libssh2 team