From 5283098e1316b4a811fbccaabbda71f676e86c93 Mon Sep 17 00:00:00 2001
From: Julian Smart <julian@anthemion.co.uk>
Date: Tue, 7 Jan 2003 13:49:08 +0000
Subject: [PATCH] Applied patch [ 662321 ] Port of wxWindows to Wine

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18618 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 distrib/msw/contrib.rsp    |  1 +
 docs/latex/wx/timespan.tex |  4 ++--
 include/wx/filefn.h        |  2 +-
 include/wx/longlong.h      |  1 +
 include/wx/msw/gccpriv.h   |  4 ++--
 include/wx/msw/setup0.h    |  2 +-
 include/wx/platform.h      |  2 +-
 include/wx/sckaddr.h       |  2 +-
 samples/makefile.vc        |  6 ------
 samples/samples.dsw        | 12 ------------
 src/common/datetime.cpp    |  2 +-
 src/common/dynarray.cpp    |  3 +++
 src/common/encconv.cpp     |  3 +++
 src/common/filefn.cpp      |  2 +-
 src/common/list.cpp        |  3 +++
 src/common/mimecmn.cpp     |  6 +++---
 src/common/sckaddr.cpp     |  4 ++--
 src/common/sckipc.cpp      |  2 +-
 src/common/string.cpp      |  3 +++
 src/common/wxchar.cpp      |  2 +-
 src/jpeg/jmorecfg.h        |  3 +++
 src/makeg95.env            | 24 +++++++++++++++++++++---
 src/msw/app.cpp            |  2 +-
 src/msw/dialup.cpp         |  1 +
 src/msw/fontenum.cpp       |  2 +-
 src/msw/gsocket.c          |  4 ++--
 src/msw/ole/automtn.cpp    |  1 +
 src/png/pngconf.h          |  8 ++++++--
 28 files changed, 67 insertions(+), 44 deletions(-)

diff --git a/distrib/msw/contrib.rsp b/distrib/msw/contrib.rsp
index e8bd9bcbb7..55e3f264bb 100644
--- a/distrib/msw/contrib.rsp
+++ b/distrib/msw/contrib.rsp
@@ -143,6 +143,7 @@ contrib/samples/animate/*.txt
 contrib/samples/animate/*.ico
 contrib/samples/animate/*.bmp
 contrib/samples/animate/*.rc
+contrib/samples/animate/*.gif
 contrib/samples/animate/AniTestVC.dsp
 contrib/samples/animate/AniTestVC.dsw
 
diff --git a/docs/latex/wx/timespan.tex b/docs/latex/wx/timespan.tex
index 3b5b37e15a..a46b716600 100644
--- a/docs/latex/wx/timespan.tex
+++ b/docs/latex/wx/timespan.tex
@@ -43,7 +43,7 @@ No base class
 
 \membersection{Constructors}
 
-\helpref{wxTimeSpan}{wxtimespan}
+\helpref{wxTimeSpan}{wxtimespanctor}
 
 \membersection{Accessors}
 
@@ -308,7 +308,7 @@ Returns the timespan for the given number of weeks.
 
 Returns the timespan for one week.
 
-\membersection{wxTimeSpan::wxTimeSpan}\label{wxtimespan}
+\membersection{wxTimeSpan::wxTimeSpan}\label{wxtimespanctor}
 
 \func{}{wxTimeSpan}{\void}
 
diff --git a/include/wx/filefn.h b/include/wx/filefn.h
index f679c61145..76a361e0ef 100644
--- a/include/wx/filefn.h
+++ b/include/wx/filefn.h
@@ -75,7 +75,7 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
 
 // Microsoft compiler loves underscores, feed them to it
 #if defined( __VISUALC__ ) \
-    || ( defined(__MINGW32__) && wxCHECK_W32API_VERSION( 0, 5 ) ) \
+    || ( defined(__MINGW32__) && !defined(__WINE__) && wxCHECK_W32API_VERSION( 0, 5 ) ) \
     || ( defined(__MWERKS__) && defined(__WXMSW__) )
     // functions
     #define   wxClose      _close
diff --git a/include/wx/longlong.h b/include/wx/longlong.h
index db1bc25975..83d32a77fb 100644
--- a/include/wx/longlong.h
+++ b/include/wx/longlong.h
@@ -63,6 +63,7 @@
     #define wxLongLongFmtSpec _T("I64")
 #elif (defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG >= 8)  || \
         defined(__MINGW32__) || \
+        defined(__GNUC__) || \
         defined(__CYGWIN__) || \
         defined(__WXMICROWIN__) || \
         (defined(__DJGPP__) && __DJGPP__ >= 2)
diff --git a/include/wx/msw/gccpriv.h b/include/wx/msw/gccpriv.h
index 41d363014a..6a3b781994 100644
--- a/include/wx/msw/gccpriv.h
+++ b/include/wx/msw/gccpriv.h
@@ -3,7 +3,7 @@
 #ifndef _WX_MSW_GCCPRIV_H_
 #define _WX_MSW_GCCPRIV_H_
 
-#if defined( __MINGW32__ ) && !defined( HAVE_W32API_H )
+#if defined( __MINGW32__ ) && !defined(__WINE__) && !defined( HAVE_W32API_H )
     #if ( __GNUC__ > 2 ) || ( ( __GNUC__ == 2 ) && ( __GNUC_MINOR__ >= 95 ) )
         #include <_mingw.h>
         #if __MINGW32_MAJOR_VERSION >= 1
@@ -24,7 +24,7 @@
 
 // Cygwin / Mingw32 with gcc >= 2.95 use new windows headers which
 // are more ms-like (header author is Anders Norlander, hence the name)
-#if (defined(__MINGW32__) || defined(__CYGWIN__)) && ((__GNUC__>2) || ((__GNUC__==2) && (__GNUC_MINOR__>=95)))
+#if (defined(__MINGW32__) || defined(__CYGWIN__) || defined(__WINE__)) && ((__GNUC__>2) || ((__GNUC__==2) && (__GNUC_MINOR__>=95)))
     #ifndef wxUSE_NORLANDER_HEADERS
         #define wxUSE_NORLANDER_HEADERS 1
     #endif
diff --git a/include/wx/msw/setup0.h b/include/wx/msw/setup0.h
index 365de9e7c0..907b31e53c 100644
--- a/include/wx/msw/setup0.h
+++ b/include/wx/msw/setup0.h
@@ -1068,7 +1068,7 @@
 // ----------------------------------------------------------------------------
 
 #ifndef wxUSE_NORLANDER_HEADERS
-#if (defined(__MINGW32__) || defined(__CYGWIN__)) && ((__GNUC__>2) ||((__GNUC__==2) && (__GNUC_MINOR__>=95)))
+#if ((defined(__MINGW32__) && defined(__CYGWIN__)) ||defined(__WINE__)) && ((__GNUC__>2) ||((__GNUC__==2) && (__GNUC_MINOR__>=95)))
 #   define wxUSE_NORLANDER_HEADERS 1
 #else
 #   define wxUSE_NORLANDER_HEADERS 0
diff --git a/include/wx/platform.h b/include/wx/platform.h
index bed5fd62c2..68e2f96480 100644
--- a/include/wx/platform.h
+++ b/include/wx/platform.h
@@ -137,7 +137,7 @@
         #define __HPUX__
     #endif /* HP-UX */
 
-    #if defined(__CYGWIN__)
+    #if defined(__CYGWIN__) || defined(__WINE__)
         #if !defined(wxSIZE_T_IS_UINT)
             #define wxSIZE_T_IS_UINT
         #endif
diff --git a/include/wx/sckaddr.h b/include/wx/sckaddr.h
index 5cdc79252c..a780b3a716 100644
--- a/include/wx/sckaddr.h
+++ b/include/wx/sckaddr.h
@@ -101,7 +101,7 @@ public:
 };
 #endif
 
-#if defined(__UNIX__) && (!defined(__WXMAC__) || defined(__DARWIN__))
+#if defined(__UNIX__) && !defined(__WINE__) && (!defined(__WXMAC__) || defined(__DARWIN__))
 #include <sys/socket.h>
 #ifndef __VMS__
 # include <sys/un.h>
diff --git a/samples/makefile.vc b/samples/makefile.vc
index ba8f85ced5..78d17950dc 100644
--- a/samples/makefile.vc
+++ b/samples/makefile.vc
@@ -136,10 +136,6 @@ all:
         nmake -f makefile.vc $(MAKEFLAGS)
         cd $(WXDIR)\samples\splitter
         nmake -f makefile.vc $(MAKEFLAGS)
-!if "$(COMPIL)"==""
-        cd $(WXDIR)\samples\tab
-        nmake -f makefile.vc $(MAKEFLAGS)
-!endif
         cd $(WXDIR)\samples\taskbar
         nmake -f makefile.vc $(MAKEFLAGS)
         cd $(WXDIR)\samples\text
@@ -252,8 +248,6 @@ clean:
         nmake -f makefile.vc clean
         cd $(WXDIR)\samples\splitter
         nmake -f makefile.vc clean
-        cd $(WXDIR)\samples\tab
-        nmake -f makefile.vc clean
         cd $(WXDIR)\samples\taskbar
         nmake -f makefile.vc clean
         cd $(WXDIR)\samples\text
diff --git a/samples/samples.dsw b/samples/samples.dsw
index 9304b71d80..6a411b9087 100644
--- a/samples/samples.dsw
+++ b/samples/samples.dsw
@@ -771,18 +771,6 @@ Package=<4>
 
 ###############################################################################
 
-Project: "tab"=.\tab\tab.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
 Project: "taskbar"=.\taskbar\taskbar.dsp - Package Owner=<4>
 
 Package=<5>
diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp
index 3ef1e1e6f1..5d04db2a3e 100644
--- a/src/common/datetime.cpp
+++ b/src/common/datetime.cpp
@@ -103,7 +103,7 @@
     #elif defined(__MWERKS__)
         long wxmw_timezone = 28800;
         #define WX_TIMEZONE wxmw_timezone
-    #elif defined(__DJGPP__)
+    #elif defined(__DJGPP__) || defined(__WINE__)
         #include <sys/timeb.h>
         #include <values.h>
         static long wxGetTimeZone()
diff --git a/src/common/dynarray.cpp b/src/common/dynarray.cpp
index 4d0ee51d28..c492d271bc 100644
--- a/src/common/dynarray.cpp
+++ b/src/common/dynarray.cpp
@@ -28,6 +28,9 @@
 
 #include <stdlib.h>
 #include <string.h> // for memmove
+#ifdef __WINE__
+#include <search.h>
+#endif
 
 #ifndef max
   #define max(a, b)   (((a) > (b)) ? (a) : (b))
diff --git a/src/common/encconv.cpp b/src/common/encconv.cpp
index e4763473e5..9c7d0d3ee6 100644
--- a/src/common/encconv.cpp
+++ b/src/common/encconv.cpp
@@ -23,6 +23,9 @@
 #include "wx/encconv.h"
 
 #include <stdlib.h>
+#ifdef __WINE__
+#include <search.h>
+#endif
 
 // conversion tables, generated by scripts in $(WXWIN)/misc/unictabl:
 #ifdef __BORLANDC__
diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp
index 950673a7d0..706a7d01cc 100644
--- a/src/common/filefn.cpp
+++ b/src/common/filefn.cpp
@@ -1262,7 +1262,7 @@ bool wxMkdir(const wxString& dir, int perm)
 
     // assume mkdir() has 2 args on non Windows-OS/2 platforms and on Windows too
     // for the GNU compiler
-#if (!(defined(__WXMSW__) || defined(__WXPM__) || defined(__DOS__))) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) || defined(__WXWINE__) || defined(__WXMICROWIN__)
+#if (!(defined(__WXMSW__) || defined(__WXPM__) || defined(__DOS__))) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) || defined(__WXWINE__) || defined(__WINE__) || defined(__WXMICROWIN__)
     if ( mkdir(wxFNCONV(dirname), perm) != 0 )
 #elif defined(__WXPM__)
     if (::DosCreateDir((PSZ)dirname, NULL) != 0) // enhance for EAB's??
diff --git a/src/common/list.cpp b/src/common/list.cpp
index e94aa517a8..54310edb27 100644
--- a/src/common/list.cpp
+++ b/src/common/list.cpp
@@ -31,6 +31,9 @@
 #include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef __WINE__
+#include <search.h>
+#endif
 
 #ifndef WX_PRECOMP
     #include "wx/defs.h"
diff --git a/src/common/mimecmn.cpp b/src/common/mimecmn.cpp
index c663f9d7bd..10bb885ac3 100644
--- a/src/common/mimecmn.cpp
+++ b/src/common/mimecmn.cpp
@@ -486,7 +486,7 @@ wxMimeTypesManager::~wxMimeTypesManager()
 
 bool wxMimeTypesManager::Unassociate(wxFileType *ft)
 {
-#if defined(__UNIX__) && !defined(__WXPM__) && !defined(__CYGWIN__) && !defined(__WXWINE__)
+#if defined(__UNIX__) && !defined(__WXPM__) && !defined(__CYGWIN__) && !defined(__WXWINE__) && !defined(__WINE__)
     return m_impl->Unassociate(ft);
 #else
     return ft->Unassociate();
@@ -596,7 +596,7 @@ size_t wxMimeTypesManager::EnumAllFileTypes(wxArrayString& mimetypes)
 void wxMimeTypesManager::Initialize(int mcapStyle,
                                     const wxString& sExtraDir)
 {
-#if defined(__UNIX__) && !defined(__WXPM__) && !defined(__CYGWIN__) && !defined(__WXWINE__)
+#if defined(__UNIX__) && !defined(__WXPM__) && !defined(__CYGWIN__) && !defined(__WXWINE__) && !defined(__WINE__)
     EnsureImpl();
 
     m_impl->Initialize(mcapStyle, sExtraDir);
@@ -609,7 +609,7 @@ void wxMimeTypesManager::Initialize(int mcapStyle,
 // and this function clears all the data from the manager
 void wxMimeTypesManager::ClearData()
 {
-#if defined(__UNIX__) && !defined(__WXPM__) && !defined(__CYGWIN__) && !defined(__WXWINE__)
+#if defined(__UNIX__) && !defined(__WXPM__) && !defined(__CYGWIN__) && !defined(__WXWINE__) && !defined(__WINE__)
     EnsureImpl();
 
     m_impl->ClearData();
diff --git a/src/common/sckaddr.cpp b/src/common/sckaddr.cpp
index b75ac6efb5..3271e93665 100644
--- a/src/common/sckaddr.cpp
+++ b/src/common/sckaddr.cpp
@@ -46,7 +46,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxIPV4address, wxSockAddress)
 #ifdef ENABLE_IPV6
 IMPLEMENT_DYNAMIC_CLASS(wxIPV6address, wxSockAddress)
 #endif
-#if defined(__UNIX__) && (!defined(__WXMAC__) || defined(__DARWIN__))
+#if defined(__UNIX__) && !defined(__WINE__) && (!defined(__WXMAC__) || defined(__DARWIN__))
 IMPLEMENT_DYNAMIC_CLASS(wxUNIXaddress, wxSockAddress)
 #endif
 
@@ -237,7 +237,7 @@ unsigned short wxIPV6address::Service()
 
 #endif // 0
 
-#if defined(__UNIX__) && (!defined(__WXMAC__) || defined(__DARWIN__))
+#if defined(__UNIX__) && !defined(__WINE__) && (!defined(__WXMAC__) || defined(__DARWIN__))
 
 // ---------------------------------------------------------------------------
 // wxUNIXaddress
diff --git a/src/common/sckipc.cpp b/src/common/sckipc.cpp
index 4151df7172..19c7e4f08e 100644
--- a/src/common/sckipc.cpp
+++ b/src/common/sckipc.cpp
@@ -89,7 +89,7 @@ static wxSockAddress *
 GetAddressFromName(const wxString& serverName, const wxString& host = _T(""))
 {
     // we always use INET sockets under non-Unix systems
-#if defined(__UNIX__) && !defined(__WXMAC__)
+#if defined(__UNIX__) && !defined(__WXMAC__) && !defined(__WINE__)
     // under Unix, if the server name looks like a path, create a AF_UNIX
     // socket instead of AF_INET one
     if ( serverName.Find(_T('/')) != wxNOT_FOUND )
diff --git a/src/common/string.cpp b/src/common/string.cpp
index 5c2e7edede..a8aefaac76 100644
--- a/src/common/string.cpp
+++ b/src/common/string.cpp
@@ -41,6 +41,9 @@
 #include <ctype.h>
 #include <string.h>
 #include <stdlib.h>
+#ifdef __WINE__
+#include <search.h>
+#endif
 
 #ifdef __SALFORDC__
   #include <clib.h>
diff --git a/src/common/wxchar.cpp b/src/common/wxchar.cpp
index ea280f7231..a2b38784dd 100644
--- a/src/common/wxchar.cpp
+++ b/src/common/wxchar.cpp
@@ -105,7 +105,7 @@ size_t WXDLLEXPORT wxWC2MB(char *buf, const wchar_t *pwz, size_t n)
 
 bool WXDLLEXPORT wxOKlibc()
 {
-#if wxUSE_WCHAR_T && defined(__UNIX__) && defined(__GLIBC__)
+#if wxUSE_WCHAR_T && defined(__UNIX__) && defined(__GLIBC__) && !defined(__WINE__)
   // glibc 2.0 uses UTF-8 even when it shouldn't
   wchar_t res = 0;
   if ((MB_CUR_MAX == 2) &&
diff --git a/src/jpeg/jmorecfg.h b/src/jpeg/jmorecfg.h
index 898c2570e9..3b6bc80758 100644
--- a/src/jpeg/jmorecfg.h
+++ b/src/jpeg/jmorecfg.h
@@ -130,6 +130,7 @@ typedef char JOCTET;
  */
 
 /* UINT8 must hold at least the values 0..255. */
+#ifndef __WINE_BASETSD_H
 
 #ifdef HAVE_UNSIGNED_CHAR
 typedef unsigned char UINT8;
@@ -155,6 +156,8 @@ typedef unsigned int UINT16;
 typedef short INT16;
 #endif
 
+#endif /* __WINE_BASETSD_H */
+
 /* INT32 must hold at least signed 32-bit values. */
 
 /*
diff --git a/src/makeg95.env b/src/makeg95.env
index 45fbe7afb4..d07503208f 100644
--- a/src/makeg95.env
+++ b/src/makeg95.env
@@ -52,12 +52,21 @@ MINGW32=1
 # gcc 3.x provides a win32api.h header
 MINGW32VERSION=3.0
 
+# If you want to compile on Wine, simply uncomment this variable
+# If you don't want to edit the file, you can simply define it
+# on the command line like so: make WINE=1 -f makefile.g95
+#WINE=1
+
 # If we're using MSYS, or other utilities that use forward slashes,
 # you need to set this when invoking the makefile from DOS, or the
 # wrong separators will be assumed. However, if you're using MSYS,
 # you really ought to invoke the makefile from MSYS--or, even better,
 # use the './configure && make' technique that MSYS is designed for.
+ifndef WINE
 #OSTYPE=msys
+else
+OSTYPE=msys
+endif
 
 # If building DLL, the version
 WXVERSION=250
@@ -133,7 +142,9 @@ ifeq (,$(findstring $(MINGW32VERSION),2.8 2.9-early 2.95-late))
 # Versions since 3.0 provide win32api.h . An old comment said to
 # define this 'if you have w32api >= 0.5', but mingw 2.95.2-1
 # has no such header.
+ifndef WINE
   _USE_W32API_HEADER_IF_SUPPORTED = -DHAVE_W32API_H
+endif
 #
 # Revision 1.70.2.6 of this file suggested '--pipe' for mingw but
 # not for cygwin, and only for version 3.0 or later. Since then,
@@ -145,11 +156,14 @@ ifeq (,$(findstring $(MINGW32VERSION),2.8 2.9-early 2.95-late))
 #
 endif
 
-# C compiler
+# Define the C++ and C compiler respectively
+ifndef WINE
 CXX = g++
-
-# C compiler
 CC = gcc
+else
+CXX = wineg++
+CC = winegcc
+endif
 
 # Compiler used for LEX generated C
 # For now at least, it can be the same as the regular C compiler
@@ -169,7 +183,11 @@ CCLEX = $(CC)
 # Settings for Cyginw/Mingw32
 # Some versions of windres cannot cope with the --preprocessor
 # option. Uncomment the RCPREPROCESSOR line below if yours can.
+ifndef WINE
 RESCOMP=windres $(_USE_TEMP_FILE_IF_SUPPORTED)
+else
+RESCOMP=wrc
+endif
 RCINPUTSWITCH=-i
 RCOUTPUTSWITCH=-o
 RCINCSWITCH=--include-dir
diff --git a/src/msw/app.cpp b/src/msw/app.cpp
index dbdba5bbe8..2361aa10f4 100644
--- a/src/msw/app.cpp
+++ b/src/msw/app.cpp
@@ -1381,6 +1381,6 @@ void wxWakeUpIdle()
 
 // For some reason, with MSVC++ 1.5, WinMain isn't linked in properly
 // if in a separate file. So include it here to ensure it's linked.
-#if (defined(__VISUALC__) && !defined(__WIN32__)) || (defined(__GNUWIN32__) && !defined(__TWIN32__) && !defined(WXMAKINGDLL))
+#if (defined(__VISUALC__) && !defined(__WIN32__)) || (defined(__GNUWIN32__) && !defined(__WINE__) && !defined(__TWIN32__) && !defined(WXMAKINGDLL))
 #include "main.cpp"
 #endif
diff --git a/src/msw/dialup.cpp b/src/msw/dialup.cpp
index 14063d3fdd..595563115d 100644
--- a/src/msw/dialup.cpp
+++ b/src/msw/dialup.cpp
@@ -55,6 +55,7 @@ DEFINE_EVENT_TYPE(wxEVT_DIALUP_DISCONNECTED)
     !defined(__GNUWIN32_OLD__) && \
     !defined(__WATCOMC__) && \
     !defined(__WXWINE__) && \
+    !defined(__WINE__) && \
     (!defined(__VISUALC__) || (__VISUALC__ >= 1020))
 
 #include <ras.h>
diff --git a/src/msw/fontenum.cpp b/src/msw/fontenum.cpp
index e92dde8150..737d099c38 100644
--- a/src/msw/fontenum.cpp
+++ b/src/msw/fontenum.cpp
@@ -152,7 +152,7 @@ bool wxFontEnumeratorHelper::SetEncoding(wxFontEncoding encoding)
     #define wxFONTENUMPROC FONTENUMPROCEX
 #elif (defined(__GNUWIN32__) && !defined(__CYGWIN10__) && !wxCHECK_W32API_VERSION( 1, 1 ))
     #if wxUSE_NORLANDER_HEADERS
-        #define wxFONTENUMPROC int(*)(const LOGFONT *, const TEXTMETRIC *, long unsigned int, LPARAM)
+        #define wxFONTENUMPROC FONTENUMPROC
     #else
         #define wxFONTENUMPROC int(*)(ENUMLOGFONTEX *, NEWTEXTMETRICEX*, int, LPARAM)
     #endif
diff --git a/src/msw/gsocket.c b/src/msw/gsocket.c
index dbdbe90fe6..6493dbfcec 100644
--- a/src/msw/gsocket.c
+++ b/src/msw/gsocket.c
@@ -26,6 +26,8 @@
 #  pragma warning(disable:4100)
 #endif /* _MSC_VER */
 
+#include <winsock.h>
+
 #ifndef __GSOCKET_STANDALONE__
 #  include "wx/defs.h"
 #  include "wx/setup.h"
@@ -56,8 +58,6 @@
 #include <stddef.h>
 #include <ctype.h>
 
-#include <winsock.h>
-
 /* if we use configure for MSW SOCKLEN_T will be already defined */
 #ifndef SOCKLEN_T
 #  define SOCKLEN_T int
diff --git a/src/msw/ole/automtn.cpp b/src/msw/ole/automtn.cpp
index de72abc752..c5c830ff1f 100644
--- a/src/msw/ole/automtn.cpp
+++ b/src/msw/ole/automtn.cpp
@@ -26,6 +26,7 @@
 // With Borland C++, all samples crash if this is compiled in.
 #if wxUSE_OLE &&!defined(__WATCOMC__) && !(defined(__BORLANDC__) && (__BORLANDC__ < 0x520)) && !defined(__CYGWIN10__) && !defined(__WXWINE__)
 
+#define _FORCENAMELESSUNION
 #include "wx/log.h"
 #include "wx/msw/ole/automtn.h"
 #include "wx/msw/private.h"
diff --git a/src/png/pngconf.h b/src/png/pngconf.h
index 738a43a44c..e4fbd8c41c 100644
--- a/src/png/pngconf.h
+++ b/src/png/pngconf.h
@@ -1157,9 +1157,13 @@ typedef z_stream FAR *  png_zstreamp;
 #  endif
 #endif
 
-#if defined(__CYGWIN__)
+#if defined(__CYGWIN__) || defined(__WINE__)
 #  undef PNGAPI
-#  define PNGAPI __cdecl
+#  if defined(__WINE__)
+#    define PNGAPI
+#  else
+#    define PNGAPI __cdecl
+#  endif
 #  undef PNG_IMPEXP
 #  define PNG_IMPEXP
 #endif
-- 
2.47.2