[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bison-generated code causes compilation failure on OpenBSD 4.7
From: |
Jim Meyering |
Subject: |
bison-generated code causes compilation failure on OpenBSD 4.7 |
Date: |
Thu, 07 Oct 2010 22:14:23 +0200 |
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.
- bison-generated code causes compilation failure on OpenBSD 4.7,
Jim Meyering <=