From: ellson Date: Sat, 8 Mar 2008 18:26:30 +0000 (+0000) Subject: Janitor - fix offsetof macro to not generate "cast from pointer to int of different... X-Git-Tag: LAST_LIBGRAPH~32^2~4548 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=16933595ebd674088b3befc32b6de3ff079f63ca;p=graphviz Janitor - fix offsetof macro to not generate "cast from pointer to int of different size" on 64bit machines. --- diff --git a/lib/cgraph/cghdr.h b/lib/cgraph/cghdr.h index 83a625fa2..e301690b8 100644 --- a/lib/cgraph/cghdr.h +++ b/lib/cgraph/cghdr.h @@ -49,6 +49,12 @@ #else #define assert(x) #endif +#ifdef HAVE_STDINT_H +#include +#endif +#ifdef HAVE_INTTYPES_H +#include +#endif #ifndef streq #define streq(s,t) ((*s == *t) && !strcmp((s),(t))) @@ -56,7 +62,11 @@ #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*) diff --git a/lib/graph/libgraph.h b/lib/graph/libgraph.h index c080ac4b2..6e79f2aa6 100644 --- a/lib/graph/libgraph.h +++ b/lib/graph/libgraph.h @@ -65,10 +65,21 @@ extern "C" { #include "graph.h" +#ifdef HAVE_STDINT_H +#include +#endif +#ifdef HAVE_INTTYPES_H +#include +#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))