Re: [xml] wsdks + winsock behaviours

2013-03-31 Thread Roumen Petrov

LRN wrote:

-BEGIN PGP SIGNED  MESSAGE- Hash: SHA1


 1) MS PSDK 7 includes winsock.h from windows.h only when compiling
 for MAC winsock.h defines _WINSOCKAPI_, it is used as #include guard

 2) mingw.org w32api includes winsock.h from windows.h only if WINVER
  0x400 (it could be reflecting that older MS PSDK used to include
 winsock.h, i wouldn't know) _WINSOCKAPI_ is never ever mentioned in
 any system header 3) mingw-w64 headers include winsock.h from
 windows.h always, unless WIN32_LEAN_AND_MEAN or __CYGWIN__ are
 defined (or __CYGWIN__ and __USE_W32_SOCKETS are defined at the same
 time) winsock.h defines _WINSOCKAPI_, it is used as #include guard

 libxml2 defines _WINSOCKAPI_ in its configure script if it detects
 mingw as the host platform
And in specific for mingw makefile (may be is up to date)
Today I don't know what is status of MSC compilers and api headers.


result: CHAOS
May be . Based on my past experience to work with second version of 
windows socket program code should use:

a)
---
#define WIN32_LEAN_AND_MEAN
#include windows.h
#include winsock2.h
---
b)
---
#include winsock2.h
#include windows.h
---
and later to call socket startup/cleanup in main application method.

If I remember well mingw.org windows. header is broken as if 
WIN32_LEAN_AND_MEAN is defined neither winsock.h or winsock2.h has to be 
included.
Also some other headers related to shell api and crypto are not included 
by default.




1) for MS PSDK 7 it does  practically nothing (unless it's MAC, in

 which case it produces _WINSOCKAPI_ redefined warning)
So may be this has to be investigated further as libxml code use this 
macro to call winsock specific methods. If is not defined in some cases 
this is issue.



2) for mingw.org w32api it does  nothing (mingw.org doesn't use

 _WINSOCKAPI_ macro at all)
This is fine with me as libxml code use this definition.


3) for mingw-w64 it produces a  warning please include winsock2.h

 before windows.h
This is not expected. Please detail.

Build with mingw.org w32 api show that winsock2.h is included before 
windows.h (based on nanohttp.c):

...
# 1590 /opt/mingw46/include/zlib.h
# 1 ./include/wsockcompat.h 1
# 12 ./include/wsockcompat.h
# 1 [HEADERPATH]/include/winsock2.h 1 3
# 17 [HEADERPATH]/include/winsock2.h 3
# 18 [HEADERPATH]/include/winsock2.h 3
# 1 [HEADERPATH]/include/windows.h 1 3
# 16 [HEADERPATH]/include/windows.h 3
# 17 [HEADERPATH]/include/windows.h 3
# 47 [HEADERPATH]/include/windows.h 3
# 1 [GCCHEADERPATH]/include/stdarg.h 1 3 4
# 102 [GCCHEADERPATH]/include/stdarg.h 3 4
# 48 [HEADERPATH]/include/windows.h 2 3
...

Roumen


___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] wsdks + winsock behaviours

2013-03-31 Thread LRN
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 31.03.2013 19:56, Roumen Petrov wrote:
 LRN wrote:
 result: CHAOS
 May be . Based on my past experience to work with second version of
  windows socket program code should use: a) --- #define
 WIN32_LEAN_AND_MEAN #include windows.h #include winsock2.h --- 
 b) --- #include winsock2.h #include windows.h --- and later to
 call socket startup/cleanup in main application method.
I prefer (b). Actually, i prefer ws2tcpip.h (it has some extra
definitions useful for apps that need rich network functionality).
ws2tcpip.h includes winsock2.h automatically. Anyway, not the point.

 
 1) for MS PSDK 7 it does  practically nothing (unless it's MAC,
 in which case it produces _WINSOCKAPI_ redefined warning)
 So may be this has to be investigated further as libxml code use
 this macro to call winsock specific methods. If is not defined in
 some cases this is issue.
Well, my statement above is theoretical. This is the limit of my
ability, as i have a copy of PSDK to look at, but i'm not going to run
MSVS to compile libxml with it.

If someone here uses MSVS or non-MSVS-driven VC, please speak up.

 
 2) for mingw.org w32api it does  nothing (mingw.org doesn't use 
 _WINSOCKAPI_ macro at all)
 This is fine with me as libxml code use this definition.
Yes, i've noticed that libxml uses _WINSOCKAPI_ as an indicator of
winsockiness of the library. You might want to choose something else.

 
 3) for mingw-w64 it produces a  warning please include
 winsock2.h before windows.h
 This is not expected. Please detail.
mingw-w64 winsock2.h has this code at the top:

#ifndef _WINSOCKAPI_
#define _WINSOCKAPI_
#else
#warning Please include winsock2.h before windows.h
#endif

and winsock.h uses _WINSOCKAPI_ as its include guard.

winsock2.h defines _WINSOCKAPI_ to prevent winsock.h from being
included (because you can't have both at the same time).

If _WINSOCKAPI_ is already defined by the time winsock2.h is included,
it means that either winsock.h defined it and was processed, or that
something else defined _WINSOCKAPI_ (which is the case with libxml).

AFAIU, libxml defines it to prevent winsock.h from being processed, in
case it includes it by accident, before winsock2.h is included. It
didn't affect mingw.org, and doesn't affect MS PSDK [anymore], and
produces a warning when used with mingw-w64. So i'd say that it's not
as effective as originally intended.
 
 Build with mingw.org w32 api show that winsock2.h is included
 before windows.h (based on nanohttp.c): ... # 1590
 /opt/mingw46/include/zlib.h # 1 ./include/wsockcompat.h 1 # 12
 ./include/wsockcompat.h # 1 [HEADERPATH]/include/winsock2.h 1
 3 # 17 [HEADERPATH]/include/winsock2.h 3 # 18
 [HEADERPATH]/include/winsock2.h 3 # 1
 [HEADERPATH]/include/windows.h 1 3 # 16
 [HEADERPATH]/include/windows.h 3 # 17
 [HEADERPATH]/include/windows.h 3 # 47
 [HEADERPATH]/include/windows.h 3 # 1
 [GCCHEADERPATH]/include/stdarg.h 1 3 4 # 102
 [GCCHEADERPATH]/include/stdarg.h 3 4 # 48
 [HEADERPATH]/include/windows.h 2 3 ...
mingw.org is set up to include winsock2.h for WINVER = 0x400 - which
means practically always (unless you're compiling for Windows 9x). So
yes, with mingw.org there's no winsock2 vs winsock infighting, unless
you're stupid enough to include winsock.h yourself.

I'd prefer to see libxml code fixed to include winsock2.h before
windows.h. If checking the code and moving includes around is
something no one wants to do, then CFLAGS+=-include winsock2.h will
help (and, obviously, all #define _WINSOCKAPI_ will have to go, or be
put under #ifdef !defined(__MINGW64_VERSION_MAJOR))

I could also try speaking with mingw-w64 devs and having them do
something similar (i.e. don't include winsock.h from windows.h).

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJRWG5KAAoJEOs4Jb6SI2Cwm+QIAJb+T9YiDEe5F47Q3oRu9RGp
0nYhKRAI6QNAae2v94xQXuHrPSXtEeND0An3+sN+yCjxKRHN8ZxeVqq+PC3Fum6g
jmkoYVpM8xDgNqQTWxbR/9gJab3pi/1O7NW5GBFqNohty+0umtFcBTyOLjeJbmsc
EnqlvFPp79qx8OfGXSkEHPX+X+2Dp/f4fbghbXdQk8gUrhKEf48rBGBEHBpnzNZx
/h6JuiSZCuB3fdJhAAklGvmMZvdEHyqcCKzHO/VPy4cO6xHjF64C3qEGQB/ILcxV
6J6oZdBwnxx8rR92XPEYp/OgcFjf/rw1DwIlPSXaRl58RdzXA1inv2Ercu8FVpQ=
=YKvA
-END PGP SIGNATURE-
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] wsdks + winsock behaviours

2013-03-31 Thread Jon
 LRN wrote:
  -BEGIN PGP SIGNED  MESSAGE- Hash: SHA1
  
   1) MS PSDK 7 includes winsock.h from windows.h only when compiling
   for MAC winsock.h defines _WINSOCKAPI_, it is used as #include guard

With MS PSDK v7.1 on my Win7 32-bit box I see something different. Windows.h 
only includes winsock.h
if WIN32_LEAN_AND_MEAN is not defined and _MAC is not defined. Something 
similar to:

  #ifndef WIN32_LEAN_AND_MEAN
  ...
  #ifndef _MAC
  ...
  #  include winsock.h
  #endif
  ...
  #endif


Jon

---
Fail fast. Fail often. Fail publicly. Learn. Adapt. Repeat.
http://thecodeshop.github.com | http://jonforums.github.com/
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] wsdks + winsock behaviours

2013-03-31 Thread LRN
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 31.03.2013 21:23, Jon wrote:
 LRN wrote:
 -BEGIN PGP SIGNED  MESSAGE- Hash: SHA1
 
 1) MS PSDK 7 includes winsock.h from windows.h only when
 compiling for MAC winsock.h defines _WINSOCKAPI_, it is used as
 #include guard
 
 With MS PSDK v7.1 on my Win7 32-bit box I see something different.
 Windows.h only includes winsock.h if WIN32_LEAN_AND_MEAN is not
 defined and _MAC is not defined. Something similar to:
 
 #ifndef WIN32_LEAN_AND_MEAN ... #ifndef _MAC ... #  include
 winsock.h #endif ... #endif
 
 
 Jon
 
...ok, i must be sleepy or something, because it's the same in 7.0,
but i mus-interpreted it.
/me re-reads carefully.
Yes, if WIN32_LEAN_AND_MEAN is not defined, and _MAC is not defined,
then winsock.h is included from windows.h.

OK. That's basically the same as mingw-w64 windows.h then, except that
MS SDK doesn't throw warnings in winsock2.h when _WINSOCKAPI_ is
already defined (other than a pre-processor warning about re-definition).

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJRWJ6AAAoJEOs4Jb6SI2Cwc88IAM2MP7fcWgIXfJOcQTaQujcJ
sq0BrOcUkBtD9uLbqiaKu35Rfn3jf8kobpbkgDEBGE3cGPShu16EYuBwDeGJFp5V
wmBpBF8Tm2/ZXlHv684KbhqGxd9hn0uIjfxzMaqDm4728dy4/BFKi8paybaMjNA2
LTujkaedSh9AGeVOpx0tY2+HkednonpPZAbH/1Pr+IFEkBIbITtYQtMvCicv4S+P
ucPGvM6ZH5NHyK+UiUF6hHJm7viorY5ikHyWDUHlcYSnWvcMWEQCw14y7ZJOclGb
bRoymCKyfpx4xPtjPqr7HnAeegGJr3Q6kt/X3yWmLFv91tImSU/4e+Cx8pcxWhw=
=Oazc
-END PGP SIGNATURE-
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml