野牛和 C++嵌套命名空间不会为我编译

发布于 2024-12-25 21:23:28 字数 896 浏览 5 评论 0原文

我一整天都在绞尽脑汁试图解决这个问题。我有一个 bison/flex/c++ 项目 我正在努力,忽略语义操作不完整并且在到达那里时会导致编译错误的事实,我无法让生成的解析器进行编译。我得到以下信息:

g++ -I. -g3 -std=c++0x -DYYDEBUG=1 -Werror -Wfatal-errors -pipe -fomit-frame-pointer -D_FORTIFY_SOURCE=2 -fstack-protector-all -o ndes.bin Parser.cpp Scanner.cpp Driver.cpp
Parser.cpp:174:3: error: prototype for ‘nde::script::Parser::Parser(nde::script::Driver&)’ does not match any in class ‘nde::script::Parser’
compilation terminated due to -Wfatal-errors.
make: *** [all] Error 1

现在,从错误来看,我认为修复起来很简单:头文件与源文件不匹配。所以,我打开它们,我找不到它们之间的区别。

我的项目的完整源代码位于上面的 github 链接中,使用“script”文件夹下的“rework”分支。我使用的是 g++ 4.6.1flex 2.5.35bison 2.4.1。有问题的文件是由 bison 生成的 Parser.[ch]pp

感谢您的帮助。

I've been banging my head all day trying to fix this. I have a bison/flex/c++ project I'm working on, ignoring the fact that the semantic actions are incomplete and will cause compile errors when it gets there, I can't get the generated parser to compile. I get the following:

g++ -I. -g3 -std=c++0x -DYYDEBUG=1 -Werror -Wfatal-errors -pipe -fomit-frame-pointer -D_FORTIFY_SOURCE=2 -fstack-protector-all -o ndes.bin Parser.cpp Scanner.cpp Driver.cpp
Parser.cpp:174:3: error: prototype for ‘nde::script::Parser::Parser(nde::script::Driver&)’ does not match any in class ‘nde::script::Parser’
compilation terminated due to -Wfatal-errors.
make: *** [all] Error 1

Now, judging from the error, I thought it would be straight forward to fix: the header file doesn't match the source file. So, I open them up, and I can't find a difference between them.

The full source to my project is in the github link above, using the "rework" branch under the "script" folder. I'm using g++ 4.6.1, flex 2.5.35, and bison 2.4.1. The files in question are Parser.[ch]pp which are generated by bison.

Thank you for any help.

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

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

发布评论

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

评论(1

呆橘 2025-01-01 21:23:28
 namespace Foo {
     class Bar;
     void x (class Bar); // refers to class Foo::Bar
     void y (class Baz); // refers to class ::Baz
 }

在命名空间中前向声明class Driver

 namespace Foo {
     class Bar;
     void x (class Bar); // refers to class Foo::Bar
     void y (class Baz); // refers to class ::Baz
 }

Forward-declare class Driver in the namespace.

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