diff dw.h @ 1102:cfe7d2b6bc16

Added DW_INT_TO_POINTER/DW_UINT_TO_POINTER/DW_POINTER_TO_INT/DW_POINTER_TO_UINT macros. These are used to cast between pointer and integers without generate warnings on 64bit systems. Converted Mac source and dwtest source to use them. Not sure if limits.h is available on all target platforms, will commit fixes as necessary.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 26 Jul 2011 03:09:41 +0000
parents 34f1d6f5f1c3
children bf932c9316ff
line wrap: on
line diff
--- a/dw.h	Tue Jul 26 00:25:57 2011 +0000
+++ b/dw.h	Tue Jul 26 03:09:41 2011 +0000
@@ -1404,6 +1404,20 @@
 /* Macro for casting resource IDs to HICN */
 #define DW_RESOURCE(a) (a < 65536 ? (HICN)a : (HICN)0)
 
+#include <limits.h>
+/* Macros for converting from INT/UINT to and from POINTER without compiler warnings */
+#if LONG_MAX > INT_MAX
+#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
+#define DW_INT_TO_POINTER(a) ((void *)a)
+#define DW_POINTER_TO_INT(a) ((int)a)
+#define DW_UINT_TO_POINTER(a) ((void *)a)
+#define DW_POINTER_TO_UINT(a) ((unsigned int)a)
+#endif
+
 #ifndef API
 #define API
 #endif