This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RFA : adding `offsetof' to system.h


Trying to bootstrap gcc on m68k-motorola-sysv, I got :

cc -c  -DIN_GCC    -g   -DHAVE_CONFIG_H    -I. -I/gcc -I/gcc/config -I/gcc/../include /gcc/cpphash.c
"/gcc/cpphash.c", line 264: syntax error
gnumake[2]: *** [cpphash.o] Error 1

That actually happens on the following line :

    U_CHAR *p = (U_CHAR *)hp + offsetof (HASHNODE, name);

because `offsetof' is not defined, and it appears in an initialization.

Here is a fix :
OK to commit ?

Philippe De Muyter  <phdm@macqel.be>

	* ggc-simple.c (offsetof): Macro definition moved from here ...
	* system.h (offsetof): ... to here.

Index: gcc/ggc-simple.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/ggc-simple.c,v
retrieving revision 1.32
diff -u -p -r1.32 ggc-simple.c
--- ggc-simple.c	2000/04/28 00:59:39	1.32
+++ ggc-simple.c	2000/05/12 11:44:48
@@ -28,10 +28,6 @@
 #include "ggc.h"
 #include "timevar.h"
 
-#ifndef offsetof
-#define offsetof(TYPE, MEMBER)	((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
 /* Debugging flags.  */
 
 /* Zap memory before freeing to catch dangling pointers.  */
Index: gcc/system.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/system.h,v
retrieving revision 1.67
diff -u -p -r1.67 system.h
--- system.h	2000/05/05 16:27:45	1.67
+++ system.h	2000/05/12 11:45:00
@@ -50,6 +50,10 @@ Boston, MA 02111-1307, USA.  */
 #define NULL 0
 #endif
 
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER)	((size_t) &((TYPE *)0)->MEMBER)
+#endif
+
 /* The compiler is not a multi-threaded application and therefore we
    do not have to use the locking functions.
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]