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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8734445/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 17:31:57  来源:igfitidea点击:

Eclipse CDT Generate method stubs from header file?

c++eclipseeclipse-cdt

提问by

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!

我想知道是否有一个用于 eclipse 的命令或插件,它会采用我的头文件并从该头文件中自动生成所有方法存根到 CPP 文件中?我已经用谷歌搜索过,但没有结果会说明不是这样,但我可以在模板下的 CDT 首选项中看到有一个选项可以启用存根生成......但找不到使用它的命令。谢谢!

回答by

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.

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

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.

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

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.

出于某种原因,毕竟有很多人试图编辑我的答案以完全改变它。所有编辑试图传达的是,显然有一个 CTRL+3 快捷方式可以调出实现方法窗口。

回答by George Geschwend

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

我在 Eclipse CDT 中有点迷失,找不到上述的实施方法选择。所以为了清楚起见,我发布了这个。

In Eclipse CDT Mars(and maybe previous versions):

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

  1. Right clickon white-space inside the .h or headerfile. Initial menu appears...
  2. Clickon Source->Implement Method...
  3. Popup window appears; checkmethods (stubs) to createin .cpp/ implementationfile.
  1. 右键单击.h 或头文件中的空格。出现初始菜单...
  2. 点击- >实现方法...
  3. 弹出窗口出现检查方法(存根)来创建英寸 cpp/实现文件。

.

.

回答by itmuckel

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.

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

Edit:

编辑:

On my blog http://itmuckel.deI 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

在我的博客http://itmuckle.de 上,我写了一篇关于在 Eclipse 中集成 Lazy C++ 的文章。它真的很好用。这里是教程的直接下载链接: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.

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