Commit e3890546 authored by Nick Wellnhofer's avatar Nick Wellnhofer

Fix the Windows header mess

Don't include windows.h and wsockcompat.h from config.h but only when
needed.

Don't define _WINSOCKAPI_ manually. This was apparently done to stop
windows.h from including winsock.h which is a problem if winsock2.h
wasn't included first. But on MinGW, this causes compiler warnings.
Define WIN32_LEAN_AND_MEAN instead which has the same effect.

Always use the compiler-defined _WIN32 macro instead of WIN32.
parent bee8f1e4
......@@ -1640,7 +1640,6 @@ case "$host" in
CPPFLAGS="$CPPFLAGS -DWIN32"
WIN32_EXTRA_LIBADD="-lws2_32"
WIN32_EXTRA_LDFLAGS="-no-undefined"
AC_DEFINE([_WINSOCKAPI_],1,[Using the Win32 Socket implementation])
if test "${PYTHON}" != ""
then
WIN32_EXTRA_PYTHON_LIBADD="-L${pythondir}/../../libs -lpython$(echo ${PYTHON_VERSION} | tr -d .)"
......
......@@ -48,7 +48,7 @@
#else
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#elif defined(WIN32)
#elif defined(_WIN32)
typedef unsigned __int32 uint32_t;
#endif
#endif
......
......@@ -16,7 +16,7 @@
#ifdef LIBXML_FTP_ENABLED
/* Needed for portability to Windows 64 bits */
#if defined(__MINGW32__) || defined(_WIN32_WCE)
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <winsock2.h>
#else
/**
......
......@@ -10,7 +10,6 @@
#if defined(_WIN32_WCE)
#undef HAVE_ERRNO_H
#include <windows.h>
#include "wincecompat.h"
#else
#define HAVE_SYS_STAT_H
......@@ -29,10 +28,6 @@
#define ICONV_CONST const
#endif
#ifdef NEED_SOCKETS
#include <wsockcompat.h>
#endif
/*
* Windows platforms may define except
*/
......
......@@ -12,8 +12,6 @@
#define HAVE_NETINET_IN_H
#define HAVE_NETDB_H
#define HAVE_SYS_TIME_H
#else /* TESTING */
#define NEED_SOCKETS
#endif /* TESTING */
#define IN_LIBXML
......@@ -77,12 +75,8 @@
#endif
#if defined(__MINGW32__) || defined(_WIN32_WCE)
#ifndef _WINSOCKAPI_
#define _WINSOCKAPI_
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <wsockcompat.h>
#include <winsock2.h>
#endif
/**
......
......@@ -11,7 +11,6 @@
* daniel@veillard.com
*/
#define NEED_SOCKETS
#define IN_LIBXML
#include "libxml.h"
......@@ -74,12 +73,8 @@
#define XML_SOCKLEN_T unsigned int
#endif
#if defined(__MINGW32__) || defined(_WIN32_WCE)
#ifndef _WINSOCKAPI_
#define _WINSOCKAPI_
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <wsockcompat.h>
#include <winsock2.h>
#endif
#include <libxml/globals.h>
......
......@@ -333,9 +333,6 @@
#define below would cause a syntax error. */
#undef _UINT32_T
/* Using the Win32 Socket implementation */
#undef _WINSOCKAPI_
/* ss_family is not defined here, use __ss_family instead */
#undef ss_family
......
......@@ -38,7 +38,7 @@
#define IN_LIBXML
#include "libxml.h"
#if defined(WIN32) && !defined (__CYGWIN__)
#if defined(_WIN32) && !defined (__CYGWIN__)
#define XML_DIR_SEP '\\'
#else
#define XML_DIR_SEP '/'
......
......@@ -10,7 +10,7 @@
#define IN_LIBXML
#include "libxml.h"
#if defined(WIN32) && !defined (__CYGWIN__)
#if defined(_WIN32) && !defined (__CYGWIN__)
#define XML_DIR_SEP '\\'
#else
#define XML_DIR_SEP '/'
......
......@@ -4021,7 +4021,7 @@ thread_specific_data(void *private_data)
return ((void *) Okay);
}
#if defined WIN32
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <windows.h>
#include <string.h>
......
......@@ -27,6 +27,7 @@
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
#elif defined HAVE_WIN32_THREADS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#ifndef HAVE_COMPILER_TLS
#include <process.h>
......
......@@ -24,14 +24,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#else
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#elif defined(WIN32)
#elif defined(_WIN32)
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#endif
#endif
#ifndef MK_UINT64
#if defined(WIN32) && defined(_MSC_VER) && _MSC_VER < 1300
#if defined(_MSC_VER) && _MSC_VER < 1300
#define MK_UINT64(x) ((uint64_t)(x))
#else
#define MK_UINT64(x) x##ULL
......
......@@ -71,11 +71,9 @@ LDFLAGS += -Wl,--minor-image-version,$(LIBXML_MINOR_VERSION)
LDFLAGS += -Wl,-L,$(BINDIR) -Wl,-L,$(LIBPREFIX)
LIBS =
ifeq ($(WITH_FTP),1)
CFLAGS += -D_WINSOCKAPI_
LIBS += -lwsock32 -lws2_32
endif
ifeq ($(WITH_HTTP),1)
CFLAGS += -D_WINSOCKAPI_
LIBS += -lwsock32 -lws2_32
endif
ifeq ($(WITH_ICONV),1)
......
......@@ -43,7 +43,7 @@ CPPFLAGS = $(CPPFLAGS) /D "_REENTRANT"
# The compiler and its options.
CC = cl.exe
CFLAGS = /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "NOLIBTOOL" /W1 $(CRUNTIME)
CFLAGS = /nologo /D "_WINDOWS" /D "_MBCS" /D "NOLIBTOOL" /W1 $(CRUNTIME)
CFLAGS = $(CFLAGS) /I$(XML_SRCDIR) /I$(XML_SRCDIR)\include /I$(INCPREFIX)
!if "$(WITH_THREADS)" != "no"
CFLAGS = $(CFLAGS) /D "_REENTRANT"
......
......@@ -9,7 +9,6 @@
#if defined(_WIN32_WCE)
#undef HAVE_ERRNO_H
#include <windows.h>
#include "wincecompat.h"
#else
#define HAVE_SYS_STAT_H
......@@ -28,10 +27,6 @@
#define ICONV_CONST const
#endif
#ifdef NEED_SOCKETS
#include <wsockcompat.h>
#endif
/*
* Windows platforms may define except
*/
......
......@@ -40,7 +40,8 @@
#include <lzma.h>
#endif
#if defined(WIN32) || defined(_WIN32)
#if defined(_WIN32) && !defined(__CYGWIN__)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
......@@ -3829,7 +3830,7 @@ xmlParserGetDirectory(const char *filename) {
if (filename == NULL) return(NULL);
#if defined(WIN32) && !defined(__CYGWIN__)
#if defined(_WIN32) && !defined(__CYGWIN__)
# define IS_XMLPGD_SEP(ch) ((ch=='/')||(ch=='\\'))
#else
# define IS_XMLPGD_SEP(ch) (ch=='/')
......
......@@ -301,8 +301,9 @@ xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
#endif /* HAVE_SHLLOAD */
#endif /* ! HAVE_DLOPEN */
#ifdef _WIN32
#if defined(_WIN32) && !defined(__CYGWIN__)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment