[haiku-development] Re: dtc port, bison and stdlib.h header guard

  • From: Jérôme Duval <korli@xxxxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 22 Aug 2012 13:19:43 +0200

Hi François,

2012/8/22 François Revol <revol@xxxxxxx>:
> Hi,
> yesterday I tried to port dtc (the device tree compiler)
> <http://git.jdl.com/gitweb/?p=dtc.git;a=summary>, and I had a strange
> issue with bison:
>
> ...
>          CC dtc-parser.tab.o
> cc1: warnings being treated as errors
> dtc-parser.tab.c:330:7: error: redundant redeclaration of 'malloc'
> dtc-parser.tab.c:337:6: error: redundant redeclaration of 'free'
> make: *** [dtc-parser.tab.o] Error 1
>
>
>
> It seems the code it generates tries to re-declare malloc() and free()
> if it didn't find glibc/linux/whatever's header guard for stdlib, which
> is _STDLIB_H, and some other weird conditions.
> Sadly it seems like ours is _STDLIB_H_, so obviously it doesn't notice
> we already have it, even with an explicit include in the .y file.
>
> Forcing the glibc guard define seems to work around it but it's not
> really clean.
>
> I'm not sure trying to fix bison is much better/simpler.
>
> The simplest solution seems to align to glibc and switch the guard to
> _STDLIB_H. I don't like it either but at least it shouldn't do any harm.
>
> Comments?

Please update your bison to 2.5. It should/could be fixed there if I
read the changelog right.

Fix portability problem on OpenBSD 4.7.

        Jim Meyering reported this in
        <http://lists.gnu.org/archive/html/bug-bison/2010-10/msg00007.html>.
        * data/yacc.c: Use EXIT_SUCCESS as a witness for stdlib.h,
        not _STDLIB_H.  EXIT_SUCCESS has been defined by the standard
        for quite some time.
        * src/parse-gram.c, src/parse-gram.h: Regenerate.
        * tests/regression.at: Tamper with the renamed witness.

Bye,
Jérôme

Other related posts: