Eclipse CDT 从头文件生成方法存根?

发布于 2024-12-25 02:12:02 字数 134 浏览 3 评论 0原文

我想知道 eclipse 是否有一个命令或插件可以获取我的头文件并从该头文件自动生成所有方法存根到 CPP 文件中?我用谷歌搜索过,缺乏结果表明并非如此,但我可以在模板下的 CDT 首选项中看到有一个选项可以启用存根生成...但找不到使用它的命令。谢谢!

I'm wondering if there is a command or plugin for eclipse that will take a header file of mine and auto-generate all of the method stubs into the CPP file from that header? I've googled and the lack of results would say not so, yet I can see in the CDT preferences under templates that there is an option to enable stub generation... but cannot find the command to use it. Thanks!

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

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

发布评论

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

评论(3

初见终念 2025-01-01 02:12:02

好吧,经过更多搜索后,我自己找到了解决方案。在头文件中,右键单击空白区域并选择“实现方法”,将出现一个窗口,显示头文件中的方法声明列表。您可以选择部分或全部,然后单击“完成”并完成它,或单击“下一步”以按照向导向导过程的其余部分进行操作。

编辑
我有时注意到,在使用它时,生成的存根的格式可能会被搞乱,或者可能会搞乱现有 CPP 文件的格式。如果确实发生这种情况,只需右键单击 CPP 文件空白区域,单击“源”并选择“格式”即可纠正问题。

另一次编辑

由于某种原因,经过这么长时间,有很多人试图编辑我的答案以彻底改变它。所有编辑试图传达的信息是,显然有一个 CTRL+3 快捷方式可以打开实施方法窗口。

Okay so, after doing some more searching I found the solution myself. In the header file, right click in white space and select "Implement Method" and a window will appear showing a list of method declarations within the header. You can select some or all, then click "Finish" and be done with it or "Next" to follow the rest of the guided wizard process.

Edit
I've noticed at times when using this that the formatting of the generated stubs can be screwed up, or can screw up the formatting of your existing CPP file. If that does happen, just right click within the CPP file white space, click "Source" and select "Format" to correct the issue.

Another Edit

For some reason after all this time, there's been a bunch of activity of people trying to edit my answer to change it completely. All the edit is trying to communicate is that there is apparently a CTRL+3 shortcut to bring up the implement methods window.

·深蓝 2025-01-01 02:12:02

我在 Eclipse CDT 中有点迷失,找不到上述的 Implement Method 选择。因此,为了清楚起见,我发布了此内容。

Eclipse CDT Mars(可能还有以前的版本)中:

  1. 右键单击.h 或标头文件内的空白区域。出现初始菜单...
  2. 单击->实现方法...
  3. 出现弹出窗口检查方法(存根)以在 .cpp / 实现文件中创建

I got a little lost in the Eclipse CDT and could not find the Implement Method selection described above. So for clarity sake I am posting this.

In Eclipse CDT Mars (and maybe previous versions):

  1. Right click on white-space inside the .h or header file. Initial menu appears...
  2. Click on Source->Implement Method...
  3. Popup window appears; check methods (stubs) to create in .cpp / implementation file.

.

人事已非 2025-01-01 02:12:02

您还可以查看 http://www.lazycplusplus.com/。它比生成方法存根更强大。它生成头文件和源文件。我设法将它集成到 Visual Studio 中,因此它可以在每个构建上运行。也许您也可以在 Eclipse 中做到这一点。

编辑:

在我的博客http://itmuckel.de上我写了一篇关于集成Lazy C++的文章在日食中。效果真的很好。以下是教程的直接下载链接:http://itmuckel.de/ wp-content/uploads/2016/04/lzz_integration.pdf

它是用德语编写的,但 Eclipse 的屏幕截图显示的是英文版本。除此之外,谷歌翻译也能做得很好。

You could also check out http://www.lazycplusplus.com/. It is more powerful than generating method-stubs. It generates header and source files. I managed to integrate it in Visual Studio, so it runs on every build. Maybe you can do that in Eclipse, too.

Edit:

On my blog http://itmuckel.de I wrote an article about integrating Lazy C++ in Eclipse. It works really good. Here is the direct downloadlink of the tutorial: http://itmuckel.de/wp-content/uploads/2016/04/lzz_integration.pdf

It is written in german, but the screenshots of Eclipse show the english version. Besides that Google Translate will do a good job, too.

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