From 1b9acd9ada1b5ec68cf89bb65b689740a0675aba Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 6 May 2002 10:28:43 +0000 Subject: [PATCH] Avoid g++-3.1 offsetof warnings. --- ChangeLog | 4 ++++ src/base/cl_offsetof.h | 10 ++++++++-- src/base/digitseq/cl_DS.h | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d1dbcd1..9528338 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2002-05-05 Bruno Haible + Avoid g++ 3.1 warnings. + * src/base/cl_offsetof.h (offsetof): Redefine each time. + * src/base/digitseq/cl_DS.h: Include "cl_offsetof.h" after . + Avoid g++ 3.1 warnings. * src/base/hash/cl_hash.h (struct cl_heap_hashtable): Use typename where needed. diff --git a/src/base/cl_offsetof.h b/src/base/cl_offsetof.h index 3192334..89ddaf2 100644 --- a/src/base/cl_offsetof.h +++ b/src/base/cl_offsetof.h @@ -1,7 +1,9 @@ // offsetof() and friends -#ifndef _CL_OFFSETOF_H -#define _CL_OFFSETOF_H +// in GCC 3.0/3.1 has the obscure property of redefining +// offsetof every time it is included, not just the first time. +// Therefore we do the same thing here, and make sure that this file +// gets included after each include of . #undef offsetof #if defined(__GNUG__) @@ -9,6 +11,10 @@ #else #define offsetof(type,ident) ((long)&(((type*)0)->ident)) #endif + +#ifndef _CL_OFFSETOF_H +#define _CL_OFFSETOF_H + #define offsetofa(type,ident) offsetof(type,ident[0]) #endif /* _CL_OFFSETOF_H */ diff --git a/src/base/digitseq/cl_DS.h b/src/base/digitseq/cl_DS.h index ba7fb31..246ccd8 100644 --- a/src/base/digitseq/cl_DS.h +++ b/src/base/digitseq/cl_DS.h @@ -354,6 +354,9 @@ extern void shiftxor_loop_up (uintD* xptr, const uintD* yptr, uintC count, uintC } // namespace cln #include +// Argh, gmp.h includes which erases the definition of offsetof +// that we have provided in cl_offsetof.h. Restore it. +#include "cl_offsetof.h" namespace cln {