delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/05/17/10:48:25

Date: Wed, 17 May 2000 10:35:48 -0400 (EDT)
From: "Kaveh R. Ghazi" <ghazi AT caip DOT rutgers DOT edu>
Message-Id: <200005171435.KAA24872@caip.rutgers.edu>
To: gcc-patches AT gcc DOT gnu DOT org, lauras AT softhome DOT net
Subject: Re: Minor system.h patch
Cc: djgpp-workers AT delorie DOT com
Reply-To: djgpp-workers AT delorie DOT com

 > From: Laurynas Biveinis <lauras AT softhome DOT net>
 > 
 > This kills warnings under DJGPP about 'offsetof' redefinition.
 > Current system.h defines its own offsetof macro only if it hasn't
 > been defined previously. But before that, it #includes just <stdio.h>,
 > and according to ANSI, offsetof lives in <stddef.h>. 
 > 
 > This patch includes <stddef.h> (if configure script has found it)
 > before offsetof and NULL fallback definitions.
 > 
 > 2000-05-17 Laurynas Biveinis <lauras AT softhome DOT net>
 > 
 > 	* system.h: #include <stddef.h> if HAVE_STDDEF_H defined.
 > 

It might be better to simply move the offsetof fallback definition to
the end of system.h.  We get stddef.h via libiberty.h, which is
included in system.h.  So there's no need to include stddef.h a second
time IMHO.

Does this patch fix the problem for you?


--- system.h~	Wed May 17 10:12:37 2000
+++ system.h	Wed May 17 10:12:48 2000
@@ -50,10 +50,6 @@ 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.
 
@@ -581,5 +577,8 @@ extern void abort PARAMS ((void));
 #define ENUM_BITFIELD(TYPE) unsigned int
 #endif
 
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER)	((size_t) &((TYPE *)0)->MEMBER)
+#endif
 
 #endif /* __GCC_SYSTEM_H__ */

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019