[ 
https://issues.apache.org/jira/browse/XERCESC-1849?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Boris Kolpackov updated XERCESC-1849:
-------------------------------------

    Affects Version/s:     (was: 3.0.1)
                       3.0.0

The reason why Xerces-C++ uses DLL_EXPORT instead of something more unique is 
because this is the symbol that is defined by autotools when building on 
systems that requires import/export mechanism (e.g., Mingw, Cygwin, etc.). In 
other words, this symbol indicates that the import/export mechanism should be 
turned on.

So it seems to me that it is GSL that should be fixed. While I suppose we could 
use something like XERCESC_DLL_EXPORT and then add something like this to 
XercesDefs.hpp:

#ifdef DLL_EXPORT
#define XERCESC_DLL_EXPORT
#endif

GSL would still not work with other cross-platform libraries that use the 
DLL_EXPORT macro since that's what is hard-coded by autotools.


> Xerces-C and GSL: conflicting Macro "DLL_EXPORT" on Windows
> -----------------------------------------------------------
>
>                 Key: XERCESC-1849
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1849
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Build
>    Affects Versions: 3.0.0
>         Environment: Visual Studio 2008, Vista x64 (testing system)
> - this bug should affect all MSVC builds
>            Reporter: --
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> When using XERCES 3.0 and GSL (here 1.8 - but 1.11 still has the same issue) 
> a MACRO conflict will occur, when using Xerces' DLL in a project which at the 
> same time uses GSL dlls.
> The conflicting Macro is  "DLL_EXPORT". In gsl-1.8\include\gsl\gsl_types.h 
> you will find:
> #ifdef WIN32
> #  ifdef GSL_DLL
> #    ifdef DLL_EXPORT
> #      define GSL_VAR extern __declspec(dllexport)
> #      define GSL_EXPORT __declspec(dllexport)
> #    else
> #      define GSL_VAR extern __declspec(dllimport)
> #      define GSL_EXPORT __declspec(dllimport)
> #    endif
> #  else
> #    define GSL_VAR extern
> #    define GSL_EXPORT
> #  endif
> #else
> #  define GSL_VAR extern
> #  define GSL_EXPORT
> #endif
> In XERCES'  xerces-c-3.0.0\src\xercesc\util\Xerces_autoconf_config.msvc.hpp
> #ifdef XERCES_STATIC_LIBRARY
> #define XERCES_PLATFORM_EXPORT
> #define XERCES_PLATFORM_IMPORT
> #else
> #define XERCES_PLATFORM_EXPORT __declspec(dllexport)
> #define XERCES_PLATFORM_IMPORT __declspec(dllimport)
> #ifndef OPENMS_XERCESDLL
> #define DLL_EXPORT
> #endif
> #endif
> and xerces-c-3.0.0\src\xercesc\util\XercesDefs.hpp
> #if defined(DLL_EXPORT)
>   #if defined(XERCES_BUILDING_LIBRARY)
>     #define XMLUTIL_EXPORT XERCES_PLATFORM_EXPORT
>     #define XMLPARSER_EXPORT XERCES_PLATFORM_EXPORT
>     #define SAX_EXPORT XERCES_PLATFORM_EXPORT
>     #define SAX2_EXPORT XERCES_PLATFORM_EXPORT
>     #define CDOM_EXPORT XERCES_PLATFORM_EXPORT
>     #define PARSERS_EXPORT  XERCES_PLATFORM_EXPORT
>     #define VALIDATORS_EXPORT  XERCES_PLATFORM_EXPORT
>     #define XINCLUDE_EXPORT  XERCES_PLATFORM_EXPORT
>   #else
>     #define XMLUTIL_EXPORT XERCES_PLATFORM_IMPORT
>     #define XMLPARSER_EXPORT XERCES_PLATFORM_IMPORT
>     #define SAX_EXPORT XERCES_PLATFORM_IMPORT
>     #define SAX2_EXPORT XERCES_PLATFORM_IMPORT
>     #define CDOM_EXPORT XERCES_PLATFORM_IMPORT
>     #define PARSERS_EXPORT  XERCES_PLATFORM_IMPORT
>     #define VALIDATORS_EXPORT  XERCES_PLATFORM_IMPORT
>     #define XINCLUDE_EXPORT  XERCES_PLATFORM_IMPORT
>   #endif
>   #if defined(XERCES_BUILDING_DEPRECATED_LIBRARY)
>     #define DEPRECATED_DOM_EXPORT XERCES_PLATFORM_EXPORT
>   #else
>     #define DEPRECATED_DOM_EXPORT XERCES_PLATFORM_IMPORT
>   #endif
> #else
>   #define XMLUTIL_EXPORT 
>   #define XMLPARSER_EXPORT 
>   #define SAX_EXPORT 
>   #define SAX2_EXPORT
>   #define CDOM_EXPORT
>   #define DEPRECATED_DOM_EXPORT 
>   #define PARSERS_EXPORT 
>   #define VALIDATORS_EXPORT
>   #define XINCLUDE_EXPORT
> #endif
> --
> This leads to GSL defining 
> #define GSL_VAR extern __declspec(dllexport)
> when it should be defining 
> #      define GSL_VAR extern __declspec(dllimport)
> and thus linking the third party app that uses XERCES and GSL will fail due 
> to wrong symbol names for GSL functions.
> Why doesnt XERCES use something like XERCES_DLL which external projects need 
> to define if they are using XERCES headers?
> DLL_EXPORT is quite a confusing name (especially when its also used for 
> importing).
> Workaround (2 patches):
> --- src\xercesc\util\Xerces_autoconf_config.msvc.hpp  Do Jul 24 19:24:46 2008
> +++ src\xercesc\util\Xerces_autoconf_config.msvc.hpp  Do Jan 22 14:09:09 2009
> @@ -100,8 +100,10 @@
>  #else
>  #define XERCES_PLATFORM_EXPORT __declspec(dllexport)
>  #define XERCES_PLATFORM_IMPORT __declspec(dllimport)
> +#ifndef XERCES_DLL
>  #define DLL_EXPORT
>  #endif
> +#endif
>  
>  #define XERCES_MFC_SUPPORT
>  
> PATCH #2
> --- src\xercesc\util\XercesDefs.hpp   Do Jan 22 19:13:55 2009
> +++ src\xercesc\util\XercesDefs.hpp   Do Jan 22 19:13:22 2009
> @@ -133,7 +133,7 @@
>  // The DLL_EXPORT flag should be defined on the command line during the 
> build of a DLL
>  // configure conspires to make this happen.
>  
> -#if defined(DLL_EXPORT)
> +#if ((defined(DLL_EXPORT)) || (defined(XERCES_DLL)))
>    #if defined(XERCES_BUILDING_LIBRARY)
>      #define XMLUTIL_EXPORT XERCES_PLATFORM_EXPORT
>      #define XMLPARSER_EXPORT XERCES_PLATFORM_EXPORT
> This should do the trick.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to