user562566
user562566

Reputation:

Eclipse CDT Generate method stubs from header file?

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!

Upvotes: 13

Views: 15737

Answers (3)

itmuckel
itmuckel

Reputation: 1420

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.

Upvotes: 3

George Geschwend
George Geschwend

Reputation: 183

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.

.

Upvotes: 11

user562566
user562566

Reputation:

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.

Upvotes: 20

Related Questions