Globals intended for use in a single file should be static
----------------------------------------------------------

         Key: XERCESC-1331
         URL: http://issues.apache.org/jira/browse/XERCESC-1331
     Project: Xerces-C++
        Type: Bug
    Versions: 2.5.0, 2.6.0    
 Environment: Win32, Visual Studio .NET 2003, static library
    Reporter: Jesse Pelton
    Priority: Minor


util/NetAccessors/WinSock/BinHTTPURLInputStream.cpp declares and uses several 
global variables.  These variables do not appear to be intended to be visible 
outside the module.  If this is the case, they should be declared static.

I bumped into this when trying to build the Apache XML Security code with a) 
Xerces namespace support disabled and b) a statically linked Xerces library.  
XML Security has a modified version of the BinHTTPURLInputStream class, 
including copies of the offending globals.  This results in warnings from the 
linker when it detects that the globals are multiply defined.  They should fix 
their end, too (I'll file a report there, too), but the Xerces code should 
correctly declare its intent as well.

Changing util/NetAccessors/WinSock/BinHTTPURLInputStream.cpp is simple.  The 
following lines need "static " inserted at the beginning:

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;

The result:

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;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to