Re: Problem using Bison & g++

From: Shahbaz (bshahbaz_at_gmail.com)
Date: 11/30/04


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.



Relevant Pages

  • Re: Forward declarations to static variables
    ... declaration) for variables and if you want to just declare a variable then you use "extern". ... Now I cannot understand what "static int x;" actually is: just a declaration? ... because some compilers default to C89 and the other default to C9X? ...
    (comp.lang.c)
  • [git patches] net driver updates for .26
    ... Fix a bug where the pointer never moves for dma_unmap... ... Update and fix driver debugging messages ... int reset); ... * header structure can be anywhere in the mcp. ...
    (Linux-Kernel)
  • [git patches] net driver fixes
    ... Fix NAPI state bug when Rx complete ... const struct cmac_statistics *s; ... int flag) ...
    (Linux-Kernel)
  • [git patches] net driver updates
    ... Fix locking in ethtool support ... static int au1000_init ... if (err) { ... * @adapter: board private struct ...
    (Linux-Kernel)
  • [git patches] net driver updates
    ... Fix PHY Lib support for gianfar and ucc_geth ... int mii_status; ... struct vio_dev *vio_dev) ... struct net_device *dev; ...
    (Linux-Kernel)