Using bison and C++ together --- compile with gcc or g++?? How??

Timothy Lofft <tlofft@golden.net>
26 Jan 2001 16:57:18 -0500

          From comp.compilers

Related articles
Using bison and C++ together --- compile with gcc or g++?? How?? tlofft@golden.net (Timothy Lofft) (2001-01-26)
Re: Using bison and C++ together --- compile with gcc or g++?? How?? pedwards@dmapub.dma.org (2001-01-28)
| List of all articles for this month |
From: Timothy Lofft <tlofft@golden.net>
Newsgroups: comp.compilers
Date: 26 Jan 2001 16:57:18 -0500
Organization: Golden Triangle On Line Inc.
Keywords: yacc, C++
Posted-Date: 26 Jan 2001 16:57:17 EST

Using bison for the first time (as part of a compilers class), so I'm
hoping there's a simple solution to our problems.


We are trying to compile a bison file with g++, but it gives all sorts
of errors about implicit function declarations. We also want to be
able to use our own C++ class inside bison to store various symbols.
If we include the header for the class definition, it gets worse. I
can eliminate some of the errors by adding "extern" declarations of
the function headers in the *.y file but this seems to be a silly
solution, as I'm creating declarations for such functions as free,
malloc and strcat.... there must be a better way.


Is there some standard way to use bison generated code with C++
classes? Or do we need to create a C-interface to the C++ classes and
compile the generate bison file using gcc?


I've done a fairly complete search of the Internet with seemingly no
success but if anyone has any pointers, they too would be appreciated.


Thanks,
-- Tim
[See the compilers archives for info on C++-ized versions of bison. -John]





Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.