Compiler errors “yyerror'”的多重定义;

Compiler errors “yyerror'”的多重定义;,compiler-errors,yacc,bison,lex,Compiler Errors,Yacc,Bison,Lex,对于Bison(或yacc),我如何解决错误 multiple definition of `yyerror' 我尝试了%选项noyyywrap nodefault yylineno并在顶部编写了原型。不走运 -编辑- 别客气。当我复制粘贴一个示例来使用时,我没有意识到我已经有了yyerror函数。Mm,我不确定,但“yyerror”是用户提供的函数(用于Bison)。如果你摆弄这个 %name_prefix 例如,选项 %name_prefix my_cool_parser_ 您可以使

对于Bison(或yacc),我如何解决错误

 multiple definition of `yyerror'
我尝试了
%选项noyyywrap nodefault yylineno
并在顶部编写了原型。不走运

-编辑-

别客气。当我复制粘贴一个示例来使用时,我没有意识到我已经有了yyerror函数。

Mm,我不确定,但“yyerror”是用户提供的函数(用于Bison)。如果你摆弄这个

%name_prefix
例如,选项

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

Mm,我不确定,但“yyerror”是用户提供的函数(用于Bison)。如果你摆弄这个

%name_prefix
例如,选项

%name_prefix my_cool_parser_

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

您需要以下
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.
您可以通过
-Wl,选项

   -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=yyrerror…

您需要以下
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.
您可以通过
-Wl,选项

   -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=yyrerror…

我不确定该怎么做,但我尝试了一下,结果没有成功。我不知道是否有删除它的选项。。。很奇怪。我不知道如何替换他们非常基本的yyerror(…){print(“语法错误”);}解决方案您能更具体地说明“它不起作用”吗?它肯定会打印每次遇到yyerror时(您可能需要
-Wl,--trace symbol=yyerror
,但在x86 linux上不需要),而且,鉴于yyerror是多重定义的,打印每次遇到的情况不就是直接告诉您问题出在哪里吗?(我打赌你正在用
-ly
cc
行上构建。也试着把它省略掉。)我不确定该怎么做,但我试过了,它不起作用。我不知道是否有删除它的选项。。。很奇怪。我不知道如何替换他们非常基本的yyerror(…){print(“语法错误”);}解决方案您能更具体地说明“它不起作用”吗?它肯定会打印每次遇到yyerror时(您可能需要
-Wl,--trace symbol=yyerror
,但在x86 linux上不需要),而且,鉴于yyerror是多重定义的,打印每次遇到的情况不就是直接告诉您问题出在哪里吗?(我打赌你是在用
-ly
cc
行上构建的。试着把它也去掉。)