views:

309

answers:

2

With Bison (or yacc) how do i solve the error

 multiple definition of `yyerror'

I tried %option noyywrap nodefault yylineno and writing the prototype at the top. No luck.

-edit-

nevermind. when i copied paste an example to work with i didnt realize i had a yyerror function already.

A: 

Mm, I'm not sure, but "yyerror" is a user-supplied function (for Bison). If you fiddle with the

%name_prefix

option, for example

%name_prefix my_cool_parser_

you can make it use "my_cool_parser_error" instead of yyerror. If you try doing this, does it help resolve where the error lies?

Kinopiko
+2  A: 

You need the following ld(1) option:

    -y symbol
   --trace-symbol=symbol
       Print the name of each linked file in which symbol  appears.   This
       option  may  be  given  any number of times.  On many systems it is
       necessary to prepend an underscore.

You can feed this through the cc(1) front end via -Wl,option

   -Wl,option
       Pass option as an option to the linker.  If option contains commas,
       it is split into multiple options at the commas.

So, cc -Wl,--trace-symbol=yyerror ...

DigitalRoss
i am not sure what thats suppose to do but i tried it and it did not work. I cant tell if theres an option to remove it or not... very weird. I dont know how to replace their very basic yyerror(...){print("syntax error"); } solution
acidzombie24
Could you be more specific about "it did not work"? It will most certainly print every encounter with yyerrror (you *might* need `-Wl,--trace-symbol=_yyerror` but not on x86 linux) and, given that yyerror is multiply defined, won't printing every encounter simply tell you directly where the problem is? (I bet you are building with `-ly` on the `cc` line. Try leaving that out too.)
DigitalRoss