16

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.

Robin Green
  • 32,079
  • 16
  • 104
  • 187
user2698
  • 315
  • 1
  • 3
  • 8
  • These are usually implemented via macros. I have never come across IDE features per se, though I'd love to know more. – dirkgently Feb 23 '10 at 23:58
  • I noticed you didn't tag the question as eclipse-cdt. If you're using eclipse with C you should install it http://www.eclipse.org/cdt/ – Ryu Feb 24 '10 at 01:28

2 Answers2

10

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

Ryu
  • 8,641
  • 10
  • 65
  • 98
  • 1
    Doesn't work for me in Eclipse 3.6.2 (CDT version 7.0.1.201009241320). I get asked to choose a method to implement from a list ... an empty list! Did you really mean C, and not C++? Because only C++ uses the terminology "method". – Robin Green May 28 '11 at 19:12
0

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.

dim
  • 1,697
  • 2
  • 13
  • 21