1

使用 Bison(或 yacc)我如何解决错误

 multiple definition of `yyerror'

我尝试%option noyywrap nodefault yylineno在顶部编写原型。没运气。

-编辑-

没关系。当我复制粘贴一个示例以使用时,我没有意识到我已经有一个 yyerror 函数。

4

2 回答 2

1

您需要以下ld(1)选项:

    -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.

你可以通过cc(1)前端通过 -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.

所以,cc -Wl,--trace-symbol=yyerror ...

于 2009-10-11T08:18:39.357 回答
0

嗯,我不确定,但“yyerror”是用户提供的功能(用于 Bison)。如果你摆弄

%name_prefix

选项,例如

%name_prefix my_cool_parser_

你可以让它使用“my_cool_parser_error”而不是 yyerror。如果您尝试这样做,是否有助于解决错误所在?

于 2009-10-11T06:50:46.053 回答