user2698
user2698

Reputation: 325

Auto generate header files for a C source file in an IDE

I am trying to use Eclipse and NetBeans for programming in C (not C++). Is there a feature/plugin for them which automatically keeps the source and header files in sync?

As in, when I implement a function in the source file, does it automatically insert the correct lines in the header file?

I did look at solutions like lzz, but they are not what I am looking for.

Upvotes: 16

Views: 17078

Answers (2)

dim
dim

Reputation: 1717

Agree with approach proposed by Ryu. In C, I would not automatically create declarations in headers. This should be an explicit action making public some symbol from the C module.

However if declaration/implementation are already setup and you want to modify any of them, I imagine that with Eclipse you may want to use Toggle Function Definition in a possible workflow where you copy in clipboard intermediate toggling results and paste them later over the changed declaration or implementation declaration.

Also use rename refactoring intensively when you change things.

Upvotes: 0

Ryu
Ryu

Reputation: 8749

Eclipse CDT allows you to write a prototype in the header file, and automatically add it to the C file.

Instructions

  1. Add function prototype to .h file void foobar()
  2. Select the function name "foobar" (try double clicking)
  3. In the toolbar click Source -> Implement Method
  4. Wizard it up

Thats probably the best you're gonna get out of the box

Upvotes: 10

Related Questions