On Sat, Aug 27, 2011 at 03:14:43AM -0700, David Aguilar wrote: > On Sat, Aug 27, 2011 at 02:21:40AM -0400, Brian Gernhardt wrote: > > Some of the errors look like things I could track down, but some just confuse me. If anyone else could take a look into this, it would be much appreciated. > > > > ~~ Brian G. > > > > gcc -o compat/obstack.o -c -MF compat/.depend/obstack.o.d -MMD -MP -Wall -Wdeclaration-after-statement -Werror -Wno-deprecated-declarations -I. -DUSE_ST_TIMESPEC -DSHA1_HEADER='"block-sha1/sha1.h"' -DNO_MEMMEM compat/obstack.c > > In file included from compat/obstack.c:30: > > compat/obstack.h:190: error: __block attribute can be specified on variables only > > compat/obstack.c:70: error: expected specifier-qualifier-list before ‘uintmax_t’ > > compat/obstack.c:111:24: error: exitfail.h: No such file or directory > > cc1: warnings being treated as errors > > compat/obstack.c: In function ‘print_and_abort’: > > compat/obstack.c:436: warning: implicit declaration of function ‘gettext’ > > compat/obstack.c:436: warning: incompatible implicit declaration of built-in function ‘gettext’ > > compat/obstack.c:438: error: ‘exit_failure’ undeclared (first use in this function) > > compat/obstack.c:438: error: (Each undeclared identifier is reported only once > > compat/obstack.c:438: error: for each function it appears in.) > > compat/obstack.c:439: warning: ‘noreturn’ function does return > > make: *** [compat/obstack.o] Error 1 > > > > $ gcc --version > > i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00) > > I ran into the same thing. > > This fixes it for me, but we might want to rearrange the > #includes a bit. I think this needs more work.. including > compat/obstack.h from kwset.c seems wrong. > Should we just include obstack.h in git-compat-util instead? > > I suspect that more exotic platforms may have problems > with obstack.h as well. This probably needs some testing > on SunOS, AIX, IRIX, etc. How about doing something a bit simpler instead and changing obstack.c to not make use of exit.h and exitfail.h? Then we don't have to update Makefile for all platforms needing NEEDS_OBSTACK and NEEDS_EXITFAIL. I don't understand why the ELIDE_CODE check is not sufficient. Care to explain? Something like this (tested on Linux and SunOS 5.10): -- 8< -- Subject: [PATCH RFC] obstack: Fix portability issues i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1, SunOS 5.10, and possibly others do not have exit.h and exitfail.h. Remove the use of these in obstack.c. The __block variable was renamed to block to avoid a gcc error: compat/obstack.h:190: error: __block attribute can be specified on variables only Initial-patch-by: David Aguilar <davvid@xxxxxxxxx> Reported-by: Brian Gernhardt <brian@xxxxxxxxxxxxxxxxxxxxx> Signed-off-by: Fredrik Kuivinen <frekui@xxxxxxxxx> --- compat/obstack.c | 35 ++++------------------------------- compat/obstack.h | 5 +---- kwset.c | 2 +- 3 files changed, 6 insertions(+), 36 deletions(-) diff --git a/compat/obstack.c b/compat/obstack.c index 75440d9..a89ab5b 100644 --- a/compat/obstack.c +++ b/compat/obstack.c @@ -18,17 +18,9 @@ Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#ifdef _LIBC -# include <obstack.h> -# include <shlib-compat.h> -#else -# include "obstack.h" -#endif +#include "git-compat-util.h" +#include <gettext.h> +#include "obstack.h" /* NOTE BEFORE MODIFYING THIS FILE: This version number must be incremented whenever callers compiled using an old obstack.h can no @@ -103,15 +95,6 @@ enum static void print_and_abort (void); void (*obstack_alloc_failed_handler) (void) = print_and_abort; -/* Exit value used when `print_and_abort' is used. */ -# include <stdlib.h> -# ifdef _LIBC -int obstack_exit_failure = EXIT_FAILURE; -# else -# include "exitfail.h" -# define obstack_exit_failure exit_failure -# endif - # ifdef _LIBC # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4) /* A looong time ago (before 1994, anyway; we're not sure) this global variable @@ -400,16 +383,6 @@ _obstack_memory_used (struct obstack *h) return nbytes; } -/* Define the error handler. */ -# ifdef _LIBC -# include <libintl.h> -# else -# include "gettext.h" -# endif -# ifndef _ -# define _(msgid) gettext (msgid) -# endif - # ifdef _LIBC # include <libio/iolibio.h> # endif @@ -435,7 +408,7 @@ print_and_abort (void) # else fprintf (stderr, "%s\n", _("memory exhausted")); # endif - exit (obstack_exit_failure); + exit (1); } #endif /* !ELIDE_CODE */ diff --git a/compat/obstack.h b/compat/obstack.h index 449070e..c3b681f 100644 --- a/compat/obstack.h +++ b/compat/obstack.h @@ -187,7 +187,7 @@ extern int _obstack_begin_1 (struct obstack *, int, int, void (*) (void *, void *), void *); extern int _obstack_memory_used (struct obstack *); -void obstack_free (struct obstack *__obstack, void *__block); +void obstack_free (struct obstack *obstack, void *block); /* Error handler called when `obstack_chunk_alloc' failed to allocate @@ -195,9 +195,6 @@ void obstack_free (struct obstack *__obstack, void *__block); should either abort gracefully or use longjump - but shouldn't return. The default action is to print a message and abort. */ extern void (*obstack_alloc_failed_handler) (void); - -/* Exit value used when `print_and_abort' is used. */ -extern int obstack_exit_failure; /* Pointer to beginning of object being allocated or to be allocated next. Note that this might not be the final address of the object diff --git a/kwset.c b/kwset.c index fd4515a..956ae72 100644 --- a/kwset.c +++ b/kwset.c @@ -37,7 +37,7 @@ #include "cache.h" #include "kwset.h" -#include "obstack.h" +#include "compat/obstack.h" #define NCHAR (UCHAR_MAX + 1) #define obstack_chunk_alloc xmalloc -- 1.7.6.557.gcee4 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html