Re: [xml] Problem when building libxml2 with Borland C++ 6

On Tue, Feb 07, 2006 at 12:03:22PM +1100, Eric Zurcher csiro au wrote:

I have recently learned that the libxml2 does not build with BCB6. The
problem is the result of the inclusion of the Windows header file
ws2tcpip.h by wsockcompat.h. The ws2tcpip.h header file (apparently
supplied to Borland by Microsoft) uses a macro, WS2TCPIP_INLINE, which
on non-Microsoft compilers gets defined as "extern inline". That's fine
for C++ compilation, but the "inline" directive is not recognized by BCB
when doing standard C compilation.

Arguably this is really a problem in the Borland header file, but it
would be nice if libxml2 could be compiled without having to modify the
distributed headers. The best patch I've been able to come up with so
far is this:


Index: include/wsockcompat.h
RCS file: /cvs/gnome/libxml2/include/wsockcompat.h,v
retrieving revision 1.3
diff -u -r1.3 wsockcompat.h
--- include/wsockcompat.h     4 Jan 2006 09:55:16 -0000       1.3
+++ include/wsockcompat.h     7 Feb 2006 00:54:03 -0000
@@ -10,7 +10,15 @@
 #undef HAVE_ERRNO_H
 #include <winsock2.h>
+#if defined(__BORLANDC__) && !defined(__cplusplus)
+#define extern static
+#define inline
 #include <ws2tcpip.h>
+#undef extern
+#undef inline
+#include <ws2tcpip.h>
 /* Check if ws2tcpip.h is a recent version which provides getaddrinfo()
 #if defined(GetAddrInfo)


This doesn't seem very elegant, though. Anyone have any better ideas?

  Gasp, yes that's really not nice, I would really prefer if someone 
could come with a nicer way to do this.
  Aren't Borland header using guards to avoid double definitions, maybe
something like this could be used instead.


Daniel Veillard      | Red Hat
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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