‘yyerror’的多重定义

发布于 2024-08-07 14:17:00 字数 235 浏览 5 评论 0原文

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

 multiple definition of `yyerror'

我尝试 %option noyywrap nodefault yylineno 并在顶部编写原型的错误。运气不好。

-编辑-

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雅心素梦 2024-08-14 14:17:00

您需要以下 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,option 通过 cc(1) 前端提供此选项,

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

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

酒儿 2024-08-14 14:17:00

嗯,我不确定,但“yyerror”是用户提供的函数(对于 Bison)。 如果您摆弄该

%name_prefix

例如,

%name_prefix my_cool_parser_

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

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文