Re: [xml] libxml2 IMHO broken on mingw when using as dynamic lib



On Fri, Jan 09, 2004 at 10:50:50AM +0100, Roland Schwingel wrote:
Hi...

I am using libxml2 on mingw. 2 days ago I found a strange problem in 
libxml2-2.6.4 resulting from an IMHO broken definition for mingw. I yet 
don't know whether this is already known or not (and so maybe fixed), I 
couldn't find anything in the mailinglist archive, and also have just 
subscribed to this list to report this bug. So please don't mind if this 
is already known.

What's wrong from my point of view?
include/libxml/xmlexports.h looks like this:
/* Windows platform with GNU compiler (Mingw) */
#if defined(_WIN32) && defined(__MINGW__)
 #if !defined _REENTRANT
   #define _REENTRANT
 #endif
#endif

This is IMHO wrong. First the define for mingw should be __MINGW32__ 
instead of __MINGW__ and second at least XMLPUBVAR definition is missing 
so eg. xmlFree() and friends are not really available and when using it 
on mingw xmlFree() crashes. My suggested fix for this is:

  Hum, sounds sensible

/* Windows platform with GNU compiler (Mingw) */
#if defined(_WIN32) && defined(__MINGW32__)
 #undef XMLPUBFUN
 #undef XMLPUBVAR
 #undef XMLCALL
 #if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
   #define XMLPUBFUN __declspec(dllexport)
   #define XMLPUBVAR __declspec(dllexport)
 #else
   #define XMLPUBFUN
   #if !defined(LIBXML_STATIC)
     #define XMLPUBVAR __declspec(dllimport) extern
   #else
     #define XMLPUBVAR extern
   #endif
 #endif
 #define XMLCALL __cdecl
 #if !defined _REENTRANT
   #define _REENTRANT
 #endif
#endif

It is know looking literally the same as for MSVC and appears to work.

What do you think? Is this acceptable? I don't know the rules for 

  me, not much ... I use only Linux. Others using Mingw might have a different
viewpoint, but this doesn't look bad, and you're making your point, so it's
fine from my maintainer POV.

submitting patches to libxml2 (or whether they are welcome at all), so I 
just added a diff of this change.

  Contextual diffs like yours sent to the list are just fine, and generally
goes in if they don't break regression tests and are explained.
  One thing to do though is to check agaisnt the latest version and possibly
against CVS, because the current version of xmlexports.h contains:

/* Windows platform with GNU compiler (Mingw) */
#if defined(_WIN32) && defined(__MINGW32__)
  #undef XMLPUBFUN
  #undef XMLPUBVAR
  #undef XMLCALL
  #if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
    #define XMLPUBFUN __declspec(dllexport)
    #define XMLPUBVAR __declspec(dllexport) extern
  #else
    #define XMLPUBFUN
    #if !defined(LIBXML_STATIC)
      #define XMLPUBVAR __declspec(dllimport) extern
    #else
      #define XMLPUBVAR extern
    #endif
  #endif
  #define XMLCALL __cdecl
  #if !defined _REENTRANT
    #define _REENTRANT
  #endif
#endif

  So it seems the equivalent of you patch already got in ...

Daniel


-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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