]> granicus.if.org Git - graphviz/commitdiff
Janitor - fix offsetof macro to not generate "cast from pointer to int of different...
authorellson <devnull@localhost>
Sat, 8 Mar 2008 18:26:30 +0000 (18:26 +0000)
committerellson <devnull@localhost>
Sat, 8 Mar 2008 18:26:30 +0000 (18:26 +0000)
lib/cgraph/cghdr.h
lib/graph/libgraph.h

index 83a625fa23f1c6da09b75f2746ca9c8ff55dde3b..e301690b8289340f84f05ea4ac5650d67cc0d0fa 100644 (file)
 #else
 #define assert(x)
 #endif
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
 
 #ifndef streq
 #define streq(s,t)             ((*s == *t) && !strcmp((s),(t)))
 #ifdef offsetof
 #undef offsetof
 #endif
+#ifdef HAVE_INTPTR_T
+#define offsetof(typ,fld)  ((intptr_t)(&(((typ*)0)->fld)))
+#else
 #define offsetof(typ,fld)  ((int)(&(((typ*)0)->fld)))
+#endif
 #define NOTUSED(var)   (void) var
 
 #define NILgraph                       NIL(Agraph_t*)
index c080ac4b2be16b250cb29bc65d6d099ed5becc07..6e79f2aa6d1d3e1c195e4f6f74e521e84a26d723 100644 (file)
@@ -65,10 +65,21 @@ extern "C" {
 
 #include "graph.h"
 
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
 #ifdef offsetof
 #undef offsetof
 #endif
+#ifdef HAVE_INTPTR_T
+#define offsetof(typ,fld)  ((intptr_t)(&(((typ*)0)->fld)))
+#else
 #define offsetof(typ,fld)  ((int)(&(((typ*)0)->fld)))
+#endif
 
 #ifndef NOT
 #define NOT(v)         (!(v))