Re: [xml] wsdks + winsock behaviours



On Sun, Mar 31, 2013 at 6:23 AM, 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

Actually, this is going to change.  The winsock.h header is included
from windows.h unless WIN32_LEAN_AND_MEAN is defined.  The winsock2.h
header will define _WINSOCK_H will prevent the redeclaration and
redefinition of symbols.  Winsock2.h as documented by MS should be
included before windows.h.

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


With the 4.0 release of mingw.org headers, so will they.

libxml2 defines _WINSOCKAPI_ in its configure script if it detects
mingw as the host platform


The application should not be defining this macro, it is the job of
the winsock2.h header to protect against inclusion of winsock.h.
Instead winsock2.h should be included before windows.h.

result: CHAOS
1) for MS PSDK 7 it does practically nothing (unless it's MAC, in
which case it produces "_WINSOCKAPI_ redefined" warning)

2) for mingw.org w32api it does nothing (mingw.org doesn't use
_WINSOCKAPI_ macro at all)


Correct, _WINSOCKAPI_ is a vendor variable, and should not be defined
by an application.

3) for mingw-w64 it produces a warning "please include <winsock2.h>
before <windows.h>"

As already stated, MS documents that winsock2.h should be included
before windows.h.  In fact you can include winsock2.h without
including windows.h since winsock2.h will include it.

--
Earnie
-- https://sites.google.com/site/earnieboyd


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