diff dw.h @ 1839:22225eb286e5

Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/). Currently a few things are missing, themes and HTML rendering but it builds in both 32bit and 64bit mode. There are also warnings generated by gcc every time the source calls a Windows API macro. (unused result warning).
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 19 Nov 2012 19:52:36 +0000
parents aedf5903db0a
children 3343a61f3262
line wrap: on
line diff
--- a/dw.h	Fri Nov 16 21:18:20 2012 +0000
+++ b/dw.h	Mon Nov 19 19:52:36 2012 +0000
@@ -1,4 +1,4 @@
-/* $Id$ */
+/* $Id: dw.h 1811 2012-09-27 05:09:10Z mhessling $ */
 
 #ifndef _H_DW
 #define _H_DW
@@ -1391,12 +1391,22 @@
 
 #include <limits.h>
 /* Macros for converting from INT/UINT to and from POINTER without compiler warnings */
-#if LONG_MAX > INT_MAX
+#if _MSC_VER > 1200 || (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 30100 || defined(__has_extension)
+/* There has got to be a better way to check for the intptr_t type....
+ * for now just include valid versions of Visual C and GCC plus clang.
+ */
+#define DW_INT_TO_POINTER(a) ((void *)(intptr_t)a)
+#define DW_POINTER_TO_INT(a) ((int)(intptr_t)a)
+#define DW_UINT_TO_POINTER(a) ((void *)(uintptr_t)a)
+#define DW_POINTER_TO_UINT(a) ((unsigned int)(uintptr_t)a)
+#elif ULONG_MAX > UINT_MAX
+/* If no intptr_t... ULONG is often bigger than UINT */
 #define DW_INT_TO_POINTER(a) ((void *)(long)a)
 #define DW_POINTER_TO_INT(a) ((int)(long)a)
 #define DW_UINT_TO_POINTER(a) ((void *)(unsigned long)a)
 #define DW_POINTER_TO_UINT(a) ((unsigned int)(unsigned long)a)
 #else
+/* Otherwise just fall back to standard casts */
 #define DW_INT_TO_POINTER(a) ((void *)a)
 #define DW_POINTER_TO_INT(a) ((int)a)
 #define DW_UINT_TO_POINTER(a) ((void *)a)