]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix compilation with MinGW runtime 3.22.2 and w32api 3.18.2
authorEli Zaretskii <eliz@gnu.org>
Thu, 6 Oct 2016 15:08:31 +0000 (18:08 +0300)
committerEli Zaretskii <eliz@gnu.org>
Thu, 6 Oct 2016 15:08:31 +0000 (18:08 +0300)
* nt/inc/ms-w32.h (_WIN32_WINNT) [!MINGW_W64]: Undefine before
defining to avoid redefinition warnings.

* nt/inc/sys/stat.h (_SYS_STAT_H, _INC_STAT_H): Define, to avoid
inclusion of sys/stat.h from the system headers, which could then
lead to compilation errors due to redefinition of 'struct stat'
etc.  This is needed because latest versions of MinGW runtime
include sys/stat.h from wchar.h.

* src/image.c (__MINGW_MAJOR_VERSION) [WINDOWSNT]: Temporarily
redefine to 4 to avoid conflict between 2 definitions of
MemoryBarrier.  (Bug#24613)

Do not merge to master!

nt/inc/ms-w32.h
nt/inc/sys/stat.h
src/image.c

index d1534336c490c355133f1ce7c7af60644d081c07..b4eb56222423bdb152debe9342e8b8389c81c637 100644 (file)
@@ -146,6 +146,7 @@ extern char *getenv ();
    in its system headers, and is not really compatible with values
    lower than 0x0500, so leave it alone.  */
 #ifndef MINGW_W64
+# undef _WIN32_WINNT
 # define _WIN32_WINNT 0x0400
 #endif
 
index 45bc2ea1e0c5b94421b4101a315f3cdd39df4ea5..ea14f075471022e77c1019314423e9ba7846b0f2 100644 (file)
@@ -30,6 +30,14 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 # define __MINGW_NOTHROW
 #endif
 
+/* Prevent the MinGW stat.h header from being included, ever.  */
+#ifndef _SYS_STAT_H
+# define _SYS_STAT_H
+#endif
+#ifndef _INC_STAT_H
+# define _INC_STAT_H
+#endif
+
 #include <sys/types.h>
 #include <time.h>
 
index a85d5149e7ee0bdbfa241889dfa0f126c251b2fe..78539d91d2bd392530d90d8362549ab780f85158 100644 (file)
@@ -8994,10 +8994,27 @@ svg_image_p (Lisp_Object object)
   return fmt[SVG_FILE].count + fmt[SVG_DATA].count == 1;
 }
 
+/* Some versions of glib's gatomic.h define MemoryBarrier, but MinGW
+   w32api 3.18 and later has its own definition.  The following gross
+   hack avoids the clash.  */
+# ifdef WINDOWSNT
+#  if (__W32API_MAJOR_VERSION + (__W32API_MINOR_VERSION >= 18)) >= 4
+#   define W32_SAVE_MINGW_VERSION __MINGW_MAJOR_VERSION
+#   undef __MINGW_MAJOR_VERSION
+#   define __MINGW_MAJOR_VERSION 4
+#  endif
+# endif
+
 # include <librsvg/rsvg.h>
 
 # ifdef WINDOWSNT
 
+# ifdef W32_SAVE_MINGW_VERSION
+#  undef __MINGW_MAJOR_VERSION
+#  define __MINGW_MAJOR_VERSION W32_SAVE_MINGW_VERSION
+#  undef W32_SAVE_MINGW_VERSION
+# endif
+
 /* SVG library functions.  */
 DEF_DLL_FN (RsvgHandle *, rsvg_handle_new, (void));
 DEF_DLL_FN (void, rsvg_handle_get_dimensions,