]> 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/agraph/aghdr.h
lib/agraph/attr.c

index 11b90a38b7873e2d3950d768f4ad9228cf697572..5d352814b6d4a1448318f481f8a9ada6cdcc7e2a 100644 (file)
@@ -51,6 +51,12 @@ extern "C" {
 # ifdef HAVE_UNISTD_H
 #  include             <unistd.h>
 # endif                                /* HAVE_UNISTD_H */
+# ifdef HAVE_STDINT_H
+#  include <stdint.h>
+# endif
+# ifdef HAVE_INTTYPES_H
+#  include <inttypes.h>
+# endif
 #endif                         /* HAVE_AST */
 
 #ifdef DEBUG
@@ -65,7 +71,11 @@ extern "C" {
 #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 d171d340711e668f218b653a904dc36a38b5af58..05fc22ce643d4e0932f87a601d1d2bb651ac3425 100644 (file)
@@ -28,9 +28,9 @@
 static void freesym(Dict_t * d, Void_t * obj, Dtdisc_t * disc);
 
 Dtdisc_t AgDataDictDisc = {
-    (int) offsetof(Agsym_t, name),     /* use symbol name as key */
+    offsetof(Agsym_t, name),   /* use symbol name as key */
     -1,
-    (int) offsetof(Agsym_t, link),
+    offsetof(Agsym_t, link),
     NIL(Dtmake_f),
     freesym,
     NIL(Dtcompar_f),