Re: [xml] wsdks + winsock behaviours



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




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]