Jim Meyering wrote: > Hello, > > On an OpenBSD 4.7 system, building coreutils fails like this: > (noticed in prerelease testing) > > make[2]: Entering directory `/u/guest/meyering/coreutils-8.5.185-0ad44/lib' > CC parse-datetime.o > parse-datetime.c:590: error: conflicting types for 'malloc' > > The problematic code is from bison's skeleton: > > # ifndef YYMALLOC > # define YYMALLOC malloc > # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || > defined __C99__FUNC__ \ > || defined __cplusplus || defined _MSC_VER) > void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ > > There are two problems. > First, YYSIZE_T is defined to __SIZE_TYPE__, which is defined > to "unsigned int" (don't recall where). > That obviously fails to match the expected "size_t". > > Stepping back, malloc shouldn't even be declared here, since > this skeleton code has already included stdlib.h. > The code above attempts to detect that by testing for _STDLIB_H, > but on this system, that symbol is not defined. > Instead, OpenBSD's stdlib.h spells it as _STDLIB_H_, with > the added trailing underscore. > > When I change the above to this, it solves the problem: > > # ifndef YYMALLOC > # define YYMALLOC malloc > # if ! defined malloc && ! defined _STDLIB_H && ! defined _STDLIB_H_ \ > && (defined __STDC__ || defined __C99__FUNC__ \ > || defined __cplusplus || defined _MSC_VER) > void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ > > However, if you like this approach I'm sure you'll want to > change some of the other uses of _STDLIB_H. > > FYI, I regenerated parse-datetime.c with the latest from bison.git's > master branch, and it's the same.
I found a better way to fix it and am using that as a temporary work-around, while we wait for a fix in bison: >From 9e43bb61e60a318da34628989e8a754aee18a285 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Thu, 7 Oct 2010 23:15:00 +0200 Subject: [PATCH] parse-datetime: avoid compilation failure on OpenBSD 4.7 * lib/parse-datetime.y (_STDLIB_H) [_STDLIB_H_]: Define. This works around a compilation failure on OpenBSD 4.7: http://thread.gmane.org/gmane.comp.parsers.bison.bugs/3418 --- ChangeLog | 7 +++++++ lib/parse-datetime.y | 8 ++++++++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/ChangeLog b/ChangeLog index 45f2a69..f327621 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-10-07 Jim Meyering <meyer...@redhat.com> + + parse-datetime: avoid compilation failure on OpenBSD 4.7 + * lib/parse-datetime.y (_STDLIB_H) [_STDLIB_H_]: Define. + This works around a compilation failure on OpenBSD 4.7: + http://thread.gmane.org/gmane.comp.parsers.bison.bugs/3418 + 2010-10-07 Eric Blake <ebl...@redhat.com> docs: update cygwin progress diff --git a/lib/parse-datetime.y b/lib/parse-datetime.y index bc46e1c..a760e69 100644 --- a/lib/parse-datetime.y +++ b/lib/parse-datetime.y @@ -68,6 +68,14 @@ #include "xalloc.h" +/* Bison's skeleton tests _STDLIB_H, while some stdlib.h headers + use _STDLIB_H_ as witness. Map the latter to the one bison uses. */ +/* FIXME: this is temporary. Remove when we have a mechanism to ensure + that the version we're using is fixed, too. */ +#ifdef _STDLIB_H_ +# undef _STDLIB_H +# define _STDLIB_H 1 +#endif /* ISDIGIT differs from isdigit, as follows: - Its arg may be any int or unsigned int; it need not be an unsigned char -- 1.7.3.1.104.gc752e