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



Hi,

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 @@
 #else
 #undef HAVE_ERRNO_H
 #include <winsock2.h>
+#if defined(__BORLANDC__) && !defined(__cplusplus)
+#define extern static
+#define inline
 #include <ws2tcpip.h>
+#undef extern
+#undef inline
+#else
+#include <ws2tcpip.h>
+#endif
 /* Check if ws2tcpip.h is a recent version which provides getaddrinfo()
*/
 #if defined(GetAddrInfo)
 #define HAVE_GETADDRINFO

------------------------------------

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

(Note that this problem does not occur when building with the Borland
5.5 distribution, as that uses an earlier version of the ws2tcpip.h
file.)

Eric Zurcher
CSIRO Plant Industry
Canberra, Australia
Eric Zurcher csiro au 



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