You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@santuario.apache.org by Jesse Pelton <js...@PKC.com> on 2005/02/01 18:48:06 UTC

Minor issue in C++ library

utils/winutils/XSECBinHTTPURIInputStream.cpp borrows heavily from
xercesc/util/NetAccessors/WinSock/BinHTTPURLInputStream.cpp, including a
doubtful practice that leads to linker warnings under some
circumstances.  The fix is trivial.

The problem is that both files in question declare the same set of
global variables, and neither file properly restricts these globals to
file scope.  As a consequence, if Xerces' namespace support is disabled
and the Xerces library is statically linked, the names collide.  (I'm
not sure whether both conditions are necessary; that's just the way I
build.)

To avoid the problem (and be clear about the intended scope of these
variables), the globals in XSECBinHTTPURIInputStream.cpp should be
declared static.  The following lines:

HMODULE gWinsockLib = NULL;
LPFN_GETHOSTBYNAME gWSgethostbyname = NULL;
LPFN_INET_ADDR gWSinet_addr = NULL;
LPFN_GETHOSTBYADDR gWSgethostbyaddr = NULL;
LPFN_HTONS gWShtons = NULL;
LPFN_SOCKET gWSsocket = NULL;
LPFN_CONNECT gWSconnect = NULL;
LPFN_SEND gWSsend = NULL;
LPFN_RECV gWSrecv = NULL;
LPFN_SHUTDOWN gWSshutdown = NULL;
LPFN_CLOSESOCKET gWSclosesocket = NULL;
LPFN_WSACLEANUP gWSACleanup = NULL;

become:

static HMODULE gWinsockLib = NULL;
static LPFN_GETHOSTBYNAME gWSgethostbyname = NULL;
static LPFN_INET_ADDR gWSinet_addr = NULL;
static LPFN_GETHOSTBYADDR gWSgethostbyaddr = NULL;
static LPFN_HTONS gWShtons = NULL;
static LPFN_SOCKET gWSsocket = NULL;
static LPFN_CONNECT gWSconnect = NULL;
static LPFN_SEND gWSsend = NULL;
static LPFN_RECV gWSrecv = NULL;
static LPFN_SHUTDOWN gWSshutdown = NULL;
static LPFN_CLOSESOCKET gWSclosesocket = NULL;
static LPFN_WSACLEANUP gWSACleanup = NULL;

I've made the same suggestion to the Xerces-C crew.  See
http://issues.apache.org/jira/browse/XERCESC-1331.