[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
redefining malloc and free throw exceptions in bison 2.1
From: |
Shane Mueller |
Subject: |
redefining malloc and free throw exceptions in bison 2.1 |
Date: |
Thu, 27 Apr 2006 11:25:57 -0400 |
Hi,
I have a project for which I was using bison 2.0 successfully in a C++
project, using the following commands in my Makefile:
bison -d $(BASE_DIR)/grammar.y -o $(BASE_DIR)/grammar.tab.cpp
flex -o$(BASE_DIR)/lex.yy.c $(BASE_DIR)/Pebl.l
BTW, I'm using g++ (GCC) 4.0.3 (Ubuntu 4.0.3-1ubuntu5) and Ubuntu's
precompiled bison/yacc tools as well. I haven't re-generated the parser
in a while, and when I did recently (after upgrading to bison 2.1), I
get the following compile-time errors:
g++ -g -O3 -Wno-deprecated -Wall -pedantic -DPEBL_UNIX -c
src/base/grammar.tab.cpp -o obj/src/base/grammar.tab.o
-I/usr/include/SDL -D_REENTRANT
src/base/grammar.tab.cpp:312: error: declaration of 'void*
malloc(unsigned int)' throws different exceptions
/usr/include/stdlib.h:584: error: than previous declaration 'void*
malloc(unsigned int) throw ()'
src/base/grammar.tab.cpp:319: error: declaration of 'void free(void*)'
throws different exceptions
/usr/include/stdlib.h:597: error: than previous declaration 'void
free(void*) throw ()'
The relevant lines from the new grammar.tab.cpp, most of which don't
appear in the older version:
# ifdef YYSTACK_ALLOC
/* Pacify GCC's `empty if-body' warning. */
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# ifndef YYSTACK_ALLOC_MAXIMUM
/* The OS might guarantee only one guard page at the bottom of the stack,
and a page size can be as small as 4096 bytes. So we cannot safely
invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
to allow for a few compiler-allocated temporary stack slots. */
# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
# endif
# else
# define YYSTACK_ALLOC YYMALLOC
# define YYSTACK_FREE YYFREE
# ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
# endif
# ifdef __cplusplus
extern "C" {
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
&& (defined (__STDC__) || defined (__cplusplus)))
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
&& (defined (__STDC__) || defined (__cplusplus)))
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifdef __cplusplus
}
# endif
# endif
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
I guess this has something trying to use a c-generated parser in a C++
project, and the new improved support for C++ in bison? Note that
grammar.y contains C++ code (defining pointers to classes with new,
etc.), so I can't just compile with gcc. This seems like a bug, but I'm
not familiar enough with bison to tell for sure. I can't find any
documentation on this behavior. Is there a work-around or easy fix
other than reverting to bison 2.0?
Thanks
- redefining malloc and free throw exceptions in bison 2.1,
Shane Mueller <=