bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bison 1.30g


From: Hans Aberg
Subject: Re: Bison 1.30g
Date: Sat, 15 Dec 2001 14:54:30 +0100

At 12:52 +0100 2001/12/13, Akim Demaille wrote:
>Translations have been updated, bits have been cleaned up, bugs have
>been removed, and tarball has been uploaded.
>
>  ftp://alpha.gnu.org/gnu/bison/bison-1.30g.tar.gz   (680 kB)
>  ftp://alpha.gnu.org/gnu/bison/bison-1.30g.tar.bz2  (554 kB)

I had one problem when compiling under C++, using alloca:
Error   : undefined identifier 'size_t'
bison.simple line 280   yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T
yycount)

This error is due to that under C++, the name is std::size_t, not size_t.
Thus I changed from:

# if YYSTACK_USE_ALLOCA
#  define YYSTACK_ALLOC alloca
#  define YYSIZE_T size_t
# else
#  ifndef YYSTACK_USE_ALLOCA
#   if defined (alloca) || defined (_ALLOCA_H)
#    define YYSTACK_ALLOC alloca
#    define YYSIZE_T size_t     /* Problem here. */
...

to:
# if YYSTACK_USE_ALLOCA
#  define YYSTACK_ALLOC alloca
#  define YYSIZE_T size_t
# else
#  ifndef YYSTACK_USE_ALLOCA
#   if defined (alloca) || defined (_ALLOCA_H)
#    define YYSTACK_ALLOC alloca
#    ifdef __cplusplus             /* Now for C++. /
#     define YYSIZE_T std::size_t
#    else
#     define YYSIZE_T size_t
#    endif
...

It then compiled.

My guess is that the other YYSIZE_T should look similar. There is a trick
one can use: First in the file put:
#ifdef __cplusplus
# define YYSTD(x) std::x
#else
# define YYSTD(x) x
#endif

Then the other definitions will look like:
# if YYSTACK_USE_ALLOCA
#  define YYSTACK_ALLOC alloca
#  define YYSIZE_T YYSTD(size_t)
# else
#  ifndef YYSTACK_USE_ALLOCA
#   if defined (alloca) || defined (_ALLOCA_H)
#    define YYSTACK_ALLOC alloca
#    define YYSIZE_T YYSTD(size_t)
...

And so on. This simplifies the macros.

  Hans Aberg





reply via email to

[Prev in Thread] Current Thread [Next in Thread]