Re: Problem using Bison & g++
From: Shahbaz (bshahbaz_at_gmail.com)
Date: 11/30/04
- Next message: Roger Leigh: "Re: PROJECT IDEAS"
- Previous message: Jose Pina Coelho: "Re: Q of all time?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Nov 2004 11:20:07 -0800
Thanks Johan,
That seemed to fix the problem. I thought I had tried that but I
guess in my many attempts to remedy the problem I had overlooked it.
For a temporary fix I included the following:
#ifdef __cplusplus
extern "C" { int yylex(void);
}
#endif
This only works if your lexer is going to use standard C types. In my
case I had my own ADTs i needed to use (as is typical when writing
compilers) and needed to get rid of the extern "C". Thanks again.
Bani
"Johan" <me@knoware.nl> wrote in message news:<10q6qcb1np4e63d@corp.supernews.com>...
> Hi,
>
> you have to declare yylex to keep g++ happy.
>
> int yylex();
>
> Johan
>
> "Shahbaz" <bshahbaz@gmail.com> schreef in bericht
> news:d4529c6e.0411221622.23f806ef@posting.google.com...
> > I'm having a problem compiling my parser's C code generated by Bison.
> > The problem occurs when I use g++ but not when I use gcc. Whats
> > really odd is that I have other parsers that I compile with g++ and
> > they work fine. I cant seem to figure out what causes this
> > compilation error.
> >
> >>bison -v -d parser.y
> >>flex tkn.lex
> >>g++ -c -o lex.o lex.yy.c
> >>g++ -c -o parser.tab.o parser.tab.c
> > /usr/share/bison/bison.simple: In function 'int yyparse()':
> > /usr/share/bison/bison.simple:573: 'yylex' undeclared(first use this
> > function)
> > /usr/share/bison/bison.simple:573: (Each undeclared identifier is
> > reported only once for each function it appears in.)
> > make: *** [parser.tab.o] Error 1
> >
> > Again, this only occurs when I use g++ and not gcc. Has anyone
> > encountered this problem with Bison/g++ before? Thanks in advance
> > your help.
- Next message: Roger Leigh: "Re: PROJECT IDEAS"
- Previous message: Jose Pina Coelho: "Re: Q of all time?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|