threads / discuss / 28233

obstack fails to compile on OS X 10.7

Subject: obstack fails to compile on OS X 10.7

## tl;dr

7 messages between Aug 27, 2011 and Sep 1, 2011.

replies: 6people: 5as markdown or json

Brian Gernhardt· Aug 27, 2011, 06:21 UTC · lore
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)

David Aguilar· Aug 27, 2011, 10:14 UTC · re: Brian Gernhardt · lore

Re: obstack fails to compile on OS X 10.7

On Sat, Aug 27, 2011 at 02:21:40AM -0400, Brian Gernhardt wrote:
Show 21 quoted lines
> 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.

-- 8< --
Subject: [RFC PATCH] obstack: Fix portability issues

i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 and possibly others do not have exit.h, exitfail.h, or obstack.h. Add compat versions of these headers as well as exitfail.c from glibc.

The ELIDE_CODE check in obstack.c is not sufficient so add a separate NEEDS_OBSTACK variable to allow platforms to opt into using the compatibility versions of these files.

The __block variable was renamed to __blk to avoid a gcc error:
compat/obstack.h:190: error: __block attribute can be specified on variables only
Signed-off-by: David Aguilar <davvid@gmail.com>
Reported-by: Brian Gernhardt <brian@gernhardtsoftware.com>
---
 Makefile          |   11 +++++++++++
 compat/exit.h     |   32 ++++++++++++++++++++++++++++++++
 compat/exitfail.c |   24 ++++++++++++++++++++++++
 compat/exitfail.h |   20 ++++++++++++++++++++
 compat/obstack.c  |   19 +++----------------
 compat/obstack.h  |    2 +-
 kwset.c           |    3 ++-
 7 files changed, 93 insertions(+), 18 deletions(-)
 create mode 100644 compat/exit.h
 create mode 100644 compat/exitfail.c
 create mode 100644 compat/exitfail.h
diff --git a/Makefile b/Makefile
index 30f3812..87ad4a2 100644
--- a/Makefile
+++ b/Makefile
@@ -517,6 +517,8 @@ LIB_H += compat/bswap.h
 LIB_H += compat/cygwin.h
 LIB_H += compat/mingw.h
 LIB_H += compat/obstack.h
+LIB_H += compat/exitfail.h
+LIB_H += compat/exit.h
 LIB_H += compat/win32/pthread.h
 LIB_H += compat/win32/syslog.h
 LIB_H += compat/win32/sys/poll.h
@@ -599,6 +601,7 @@ LIB_OBJS += cache-tree.o
 LIB_OBJS += color.o
 LIB_OBJS += combine-diff.o
 LIB_OBJS += commit.o
+LIB_OBJS += compat/exitfail.o
 LIB_OBJS += compat/obstack.o
 LIB_OBJS += config.o
 LIB_OBJS += connect.o
@@ -872,6 +875,8 @@ ifeq ($(uname_S),Darwin)
 	NEEDS_CRYPTO_WITH_SSL = YesPlease
 	NEEDS_SSL_WITH_CRYPTO = YesPlease
 	NEEDS_LIBICONV = YesPlease
+	NEEDS_OBSTACK = YesPlease
+	NEEDS_EXITFAIL = YesPlease
 	ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2)
 		OLD_ICONV = UnfortunatelyYes
 	endif
@@ -1416,6 +1421,12 @@ endif
 ifdef NEEDS_RESOLV
 	EXTLIBS += -lresolv
 endif
+ifdef NEEDS_OBSTACK
+	BASIC_CFLAGS += -DNEEDS_OBSTACK
+endif
+ifdef NEEDS_EXITFAIL
+	BASIC_CFLAGS += -DNEEDS_EXITFAIL
+endif
 ifdef NO_D_TYPE_IN_DIRENT
 	BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
 endif
diff --git a/compat/exit.h b/compat/exit.h
new file mode 100644
index 0000000..9dbfb7c
--- /dev/null
+++ b/compat/exit.h
@@ -0,0 +1,32 @@
+/* exit() function.
+   Copyright (C) 1995, 2001 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _EXIT_H
+#define _EXIT_H
+
+/* Get exit() declaration.  */
+#include <stdlib.h>
+
+/* Some systems do not define EXIT_*, even with STDC_HEADERS.  */
+#ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+#endif
+#ifndef EXIT_FAILURE
+# define EXIT_FAILURE 1
+#endif
+
+#endif /* _EXIT_H */
diff --git a/compat/exitfail.c b/compat/exitfail.c
new file mode 100644
index 0000000..a2dd5dd
--- /dev/null
+++ b/compat/exitfail.c
@@ -0,0 +1,24 @@
+/* Failure exit status
+
+   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; see the file COPYING.
+   If not, write to the Free Software Foundation,
+   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+#ifdef NEEDS_EXITFAIL
+#include "exitfail.h"
+#include "exit.h"
+
+int volatile exit_failure = EXIT_FAILURE;
+#endif
diff --git a/compat/exitfail.h b/compat/exitfail.h
new file mode 100644
index 0000000..e46cf9c
--- /dev/null
+++ b/compat/exitfail.h
@@ -0,0 +1,20 @@
+/* Failure exit status
+
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; see the file COPYING.
+   If not, write to the Free Software Foundation,
+   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+extern int volatile exit_failure;
diff --git a/compat/obstack.c b/compat/obstack.c
index 75440d9..825658c 100644
--- a/compat/obstack.c
+++ b/compat/obstack.c
@@ -18,15 +18,12 @@
    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 <gettext.h>
+# include "git-compat-util.h"
 # include "obstack.h"
 #endif
 
@@ -54,7 +51,7 @@
 
 #include <stddef.h>
 
-#ifndef ELIDE_CODE
+#if !defined ELIDE_CODE || defined NEEDS_OBSTACK
 
 
 # if HAVE_INTTYPES_H
@@ -400,16 +397,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
diff --git a/compat/obstack.h b/compat/obstack.h
index 449070e..5636b91 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 *__blk);
 
 
 /* Error handler called when `obstack_chunk_alloc' failed to allocate
diff --git a/kwset.c b/kwset.c
index fd4515a..d01c562 100644
--- a/kwset.c
+++ b/kwset.c
@@ -37,7 +37,8 @@
 #include "cache.h"
 
 #include "kwset.h"
-#include "obstack.h"
+#include "git-compat-util.h"
+#include "compat/obstack.h"
 
 #define NCHAR (UCHAR_MAX + 1)
 #define obstack_chunk_alloc xmalloc
-- 
1.7.6.476.g57292
Brian Gernhardt· Aug 28, 2011, 03:57 UTC · re: David Aguilar · lore

Re: obstack fails to compile on OS X 10.7

On Aug 27, 2011, at 6:14 AM, David Aguilar wrote:
> 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?
If obstack.h is only used in kwset, I don't see a problem with it.
> -- 8< --
> Subject: [RFC PATCH] obstack: Fix portability issues
This patch does solve my compile problem.  Now to track down test failures (unrelated to this issue, I'm very sure).
~~ B
Fredrik Kuivinen· Aug 28, 2011, 20:08 UTC · re: David Aguilar · lore

Re: obstack fails to compile on OS X 10.7

On Sat, Aug 27, 2011 at 03:14:43AM -0700, David Aguilar wrote:
Show 33 quoted lines
> 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@gmail.com>
Reported-by: Brian Gernhardt <brian@gernhardtsoftware.com>
Signed-off-by: Fredrik Kuivinen <frekui@gmail.com>
---
 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
David Aguilar· Aug 29, 2011, 03:18 UTC · re: Fredrik Kuivinen · lore

Re: obstack fails to compile on OS X 10.7

On Sun, Aug 28, 2011 at 10:08:46PM +0200, Fredrik Kuivinen wrote:
Show 39 quoted lines
> 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 like this much better.  Less code is better code.
> I don't understand why the ELIDE_CODE check is not sufficient. Care to
> explain?

I can't say I know. The intention of the check is to avoid pulling in that section of code when it is already built-in to the C library. Maybe that check doesn't quite mean the same thing when the file is used alone outside of its original context?

> -void obstack_free (struct obstack *__obstack, void *__block);
> +void obstack_free (struct obstack *obstack, void *block);

Tiny nit: I know it's just a declaration but would it be advisable to drop the variable names altogether here? Having a pointer and a structure with the same "obstack" name could be confusing.

This looks good otherwise. I was a bit iffy about my patch when I had to bring in the extra headers. Doing without them is much better.

I tried your patch on top of my recent "Improve compiler header dependency check" and it worked fine.

So...
Tested-by: David Aguilar <davvid@gmail.com>
-- 
					David
Junio C Hamano· Aug 29, 2011, 06:07 UTC · re: David Aguilar · lore

Re: obstack fails to compile on OS X 10.7

David Aguilar <davvid@gmail.com> writes:
Show 5 quoted lines
>> -void obstack_free (struct obstack *__obstack, void *__block);
>> +void obstack_free (struct obstack *obstack, void *block);
>
> Tiny nit: I know it's just a declaration but would it be advisable to
> drop the variable names altogether here?

I agree. In general it is easier to read if parameter names to a function declaration is omitted, especially if it is clear from their types what they mean [*1*]. And in this case, it is.

> Tested-by: David Aguilar <davvid@gmail.com>
Thanks.
[Footnote]
*1* It is Ok to spell them out in a case like this:
    int copy(char *dst, const char *src, size_t);

You do not have to, as "char *" vs "const char *" makes it clear which one is which.

Ramsay Jones· Sep 1, 2011, 17:30 UTC · re: Fredrik Kuivinen · lore

Re: obstack fails to compile on OS X 10.7

Fredrik Kuivinen wrote:
> 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:
[snip]
>> I suspect that more exotic platforms may have problems
>> with obstack.h as well.  This probably needs some testing
>> on SunOS, AIX, IRIX, etc.
Just FYI, my cygwin and mingw builds failed in the same way as OS X ...
Show 18 quoted lines
> 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@gmail.com>
> Reported-by: Brian Gernhardt <brian@gernhardtsoftware.com>
> Signed-off-by: Fredrik Kuivinen <frekui@gmail.com>
> ---
... and this fixes the build(s) just fine[1]. Thanks!

ATB, Ramsay Jones

[1] Well the build is fine on cygwin, but the mingw build fails for an unrelated reason; compat/obstack.c compiles just fine.

← back to recent threads