diff --strip-trailing-cr -urN expat.orig/loadlibr.c expat/loadlibr.c
--- expat.orig/loadlibr.c	2024-02-13 06:16:03.142931679 +0100
+++ expat/loadlibr.c	2024-02-13 06:49:13.103221128 +0100
@@ -32,7 +32,10 @@
 
 #if defined(_WIN32)
 
-#include <windows.h>
+#if defined(UNICODE) && !defined(_UNICODE)
+#define _UNICODE
+#endif
+#include "winconfi.h"
 #include <tchar.h>
 
 
@@ -103,7 +106,7 @@
   /* Detect if KB2533623 is installed, as LOAD_LIBARY_SEARCH_SYSTEM32 is only
      supported on Windows Vista, Windows Server 2008, Windows 7 and Windows
      Server 2008 R2 with this patch or natively on Windows 8 and above */
-  else if(pLoadLibraryEx && GetProcAddress(hKernel32, "AddDllDirectory")) {
+  else if(pLoadLibraryEx && HB_WINAPI_GETPROCADDRESS(hKernel32, "AddDllDirectory")) {
     /* Load the DLL from the Windows system directory */
     hModule = pLoadLibraryEx(filename, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
   }
@@ -114,7 +117,7 @@
       /* Allocate space for the full DLL path (Room for the null terminator
          is included in systemdirlen) */
       size_t filenamelen = _tcslen(filename);
-      TCHAR *path = malloc(sizeof(TCHAR) * (systemdirlen + 1 + filenamelen));
+      TCHAR *path = (TCHAR *) malloc(sizeof(TCHAR) * (systemdirlen + 1 + filenamelen));
       if(path && GetSystemDirectory(path, systemdirlen)) {
         /* Calculate the full DLL path */
         _tcscpy(path + _tcslen(path), TEXT("\\"));
diff --strip-trailing-cr -urN expat.orig/winconfi.h expat/winconfi.h
--- expat.orig/winconfi.h	2024-02-13 06:16:03.142931679 +0100
+++ expat/winconfi.h	2017-12-20 11:37:33.337587069 +0100
@@ -1,63 +1 @@
-/*
-                            __  __            _
-                         ___\ \/ /_ __   __ _| |_
-                        / _ \\  /| '_ \ / _` | __|
-                       |  __//  \| |_) | (_| | |_
-                        \___/_/\_\ .__/ \__,_|\__|
-                                 |_| XML parser
-
-   Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
-   Copyright (c) 2000-2017 Expat development team
-   Licensed under the MIT license:
-
-   Permission is  hereby granted,  free of charge,  to any  person obtaining
-   a  copy  of  this  software   and  associated  documentation  files  (the
-   "Software"),  to  deal in  the  Software  without restriction,  including
-   without  limitation the  rights  to use,  copy,  modify, merge,  publish,
-   distribute, sublicense, and/or sell copies of the Software, and to permit
-   persons  to whom  the Software  is  furnished to  do so,  subject to  the
-   following conditions:
-
-   The above copyright  notice and this permission notice  shall be included
-   in all copies or substantial portions of the Software.
-
-   THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT  WARRANTY  OF  ANY  KIND,
-   EXPRESS  OR IMPLIED,  INCLUDING  BUT  NOT LIMITED  TO  THE WARRANTIES  OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-   NO EVENT SHALL THE AUTHORS OR  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR  OTHER LIABILITY, WHETHER  IN AN  ACTION OF CONTRACT,  TORT OR
-   OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-   USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#ifndef WINCONFIG_H
-#define WINCONFIG_H
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#undef WIN32_LEAN_AND_MEAN
-
-#include <memory.h>
-#include <string.h>
-
-
-#if defined(HAVE_EXPAT_CONFIG_H)  /* e.g. MinGW */
-# include <expat_config.h>
-#else  /* !defined(HAVE_EXPAT_CONFIG_H) */
-
-
-#define XML_NS 1
-#define XML_DTD 1
-#define XML_CONTEXT_BYTES 1024
-
-/* we will assume all Windows platforms are little endian */
-#define BYTEORDER 1234
-
-/* Windows has memmove() available. */
-#define HAVE_MEMMOVE
-
-
-#endif /* !defined(HAVE_EXPAT_CONFIG_H) */
-
-
-#endif /* ndef WINCONFIG_H */
+#include "_hbconf.h"
diff --strip-trailing-cr -urN expat.orig/xmlparse.c expat/xmlparse.c
--- expat.orig/xmlparse.c	2024-02-13 06:16:03.142931679 +0100
+++ expat/xmlparse.c	2017-12-20 12:31:54.994032713 +0100
@@ -43,6 +43,12 @@
 
 #ifdef _WIN32
 #define getpid GetCurrentProcessId
+#elif defined(__WATCOMC__) && defined(__DOS__)
+#include <process.h>                    /* getpid() */
+#include <sys/timeb.h>                  /* ftime() */
+#elif defined(__WATCOMC__) && defined(__OS2__)
+#include <process.h>                    /* getpid() */
+#include <sys/time.h>                   /* gettimeofday() */
 #else
 #include <sys/time.h>                   /* gettimeofday() */
 #include <sys/types.h>                  /* getpid() */
@@ -56,7 +62,7 @@
 #ifdef _WIN32
 #include "winconfi.h"
 #elif defined(HAVE_EXPAT_CONFIG_H)
-#include <expat_config.h>
+#include <expat_co.h>
 #endif /* ndef _WIN32 */
 
 #include "ascii.h"
@@ -783,7 +789,7 @@
 
   if (advapi32) {
     const RTLGENRANDOM_FUNC RtlGenRandom
-        = (RTLGENRANDOM_FUNC)GetProcAddress(advapi32, "SystemFunction036");
+        = (RTLGENRANDOM_FUNC)HB_WINAPI_GETPROCADDRESS(advapi32, "SystemFunction036");
     if (RtlGenRandom) {
       if (RtlGenRandom((PVOID)target, (ULONG)count) == TRUE) {
         success = 1;
@@ -803,10 +809,21 @@
 static unsigned long
 gather_time_entropy(void)
 {
-#ifdef _WIN32
+#ifdef _WINCE
+  SYSTEMTIME st;
+  GetSystemTime(&st);
+  return ( ( ( ( long ) st.wDay * 24 +
+                        st.wHour ) * 60 +
+                        st.wMinute ) * 60 +
+                        st.wSecond ) * 1000 + st.wMilliseconds;
+#elif defined(_WIN32)
   FILETIME ft;
   GetSystemTimeAsFileTime(&ft); /* never fails */
   return ft.dwHighDateTime ^ ft.dwLowDateTime;
+#elif defined(__WATCOMC__) && defined(__DOS__)
+  struct timeb tb;
+  ftime( &tb );
+  return tb.time ^ tb.millitm;
 #else
   struct timeval tv;
   int gettimeofday_res;
@@ -829,7 +846,11 @@
 
 static unsigned long
 ENTROPY_DEBUG(const char * label, unsigned long entropy) {
+#ifdef _WINCE
+  const char * const EXPAT_ENTROPY_DEBUG = NULL;
+#else
   const char * const EXPAT_ENTROPY_DEBUG = getenv("EXPAT_ENTROPY_DEBUG");
+#endif
   if (EXPAT_ENTROPY_DEBUG && ! strcmp(EXPAT_ENTROPY_DEBUG, "1")) {
     fprintf(stderr, "Entropy: %s --> 0x%0*lx (%lu bytes)\n",
         label,
@@ -7186,7 +7207,7 @@
     charsRequired++;
 
     /* Now allocate space for the copy */
-    result = memsuite->malloc_fcn(charsRequired * sizeof(XML_Char));
+    result = (XML_Char *) memsuite->malloc_fcn(charsRequired * sizeof(XML_Char));
     if (result == NULL)
         return NULL;
     /* Copy the original into place */
diff --strip-trailing-cr -urN expat.orig/xmlrole.c expat/xmlrole.c
--- expat.orig/xmlrole.c	2024-02-13 06:16:03.142931679 +0100
+++ expat/xmlrole.c	2017-12-20 11:37:33.337587069 +0100
@@ -36,7 +36,7 @@
 #include "winconfi.h"
 #else
 #ifdef HAVE_EXPAT_CONFIG_H
-#include <expat_config.h>
+#include <expat_co.h>
 #endif
 #endif /* ndef _WIN32 */
 
diff --strip-trailing-cr -urN expat.orig/xmltok.c expat/xmltok.c
--- expat.orig/xmltok.c	2024-02-13 06:16:03.142931679 +0100
+++ expat/xmltok.c	2018-09-20 12:45:24.874163719 +0200
@@ -47,7 +47,7 @@
 #include "winconfi.h"
 #else
 #ifdef HAVE_EXPAT_CONFIG_H
-#include <expat_config.h>
+#include <expat_co.h>
 #endif
 #endif /* ndef _WIN32 */
 
