help-bison
[Top][All Lists]
Advanced

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

Re: "identifier redeclared" error on SunOS with yacc


From: Joel E. Denny
Subject: Re: "identifier redeclared" error on SunOS with yacc
Date: Wed, 1 Oct 2008 03:39:28 -0400 (EDT)

On Wed, 1 Oct 2008, Umut Emin wrote:

> I have written a parser in bison which works with flex
> together. The compilation and execution work just fine
> on machines with bison. I tried to port these in
> a Sun OS where only yacc is installed

> yacc -t -d -b parser parser.y 
> mv parser.tab.h parser.h
> mv parser.tab.c parser.c
> cc -pedantic -g -o tokenizer.o -c tokenizer.c 
> cc -pedantic -g -o parser.o -c parser.c 
> "parser.y", line 66: identifier redeclared: YYSTYPE
>         current : union  {int err_code, pointer to struct def_table {..}
> def_tab, pointer to struct dec_table {..} dec_tab}
>         previous: union  {int err_code, pointer to struct def_table {..}
> def_tab, pointer to struct dec_table {..} dec_tab} : "parser.h", line 10
> "parser.y", line 159: identifier redeclared: yylval
>         current : union  {int err_code, pointer to struct def_table {..}
> def_tab, pointer to struct dec_table {..} dec_tab}
>         previous: union  {int err_code, pointer to struct def_table {..}
> def_tab, pointer to struct dec_table {..} dec_tab} : "parser.h", line 11
> cc: acomp failed for parser.c
> *** Error code 2
> make: Fatal error: Command failed for target `parser_compiling'

In parser.y, try removing:

  #include "parser.h"

parser.c should already contain the contents of parser.h.

> Now I suspect, errors are caused by one of those small differences
> between yacc and bison. Yet I can't point out the cause.

When Bison generates parser.h, it generates a cpp guard to protect against 
redefinitions of YYSTYPE.  Solaris Yacc apparently does not.




reply via email to

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