自动为IDE中的C源文件生成头文件

时间:2022-10-26 02:05:02

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?

我正在尝试使用Eclipse和NetBeans在C(而不是C ++)中进行编程。是否有一个功能/插件,它们可以自动保持源文件和头文件同步?

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.

我确实看过像lzz这样的解决方案,但它们并不是我想要的。

2 个解决方案

#1


10  

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

Eclipse CDT允许您在头文件中编写原型,并自动将其添加到C文件中。

Instructions

  1. Add function prototype to .h file void foobar()
  2. 将函数原型添加到.h文件void foobar()

  3. Select the function name "foobar" (try double clicking)
  4. 选择功能名称“foobar”(尝试双击)

  5. In the toolbar click Source -> Implement Method
  6. 在工具栏中单击“源” - >“实现方法”

  7. Wizard it up
  8. 向上推荐它

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

这可能是你开箱即用的最好的

#2


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.

同意Ryu提出的方法。在C中,我不会自动在标头中创建声明。这应该是一个明确的操作,从C模块公开一些符号。

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.

当你改变东西时,也要使用重命名重构。

#1


10  

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

Eclipse CDT允许您在头文件中编写原型,并自动将其添加到C文件中。

Instructions

  1. Add function prototype to .h file void foobar()
  2. 将函数原型添加到.h文件void foobar()

  3. Select the function name "foobar" (try double clicking)
  4. 选择功能名称“foobar”(尝试双击)

  5. In the toolbar click Source -> Implement Method
  6. 在工具栏中单击“源” - >“实现方法”

  7. Wizard it up
  8. 向上推荐它

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

这可能是你开箱即用的最好的

#2


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.

同意Ryu提出的方法。在C中,我不会自动在标头中创建声明。这应该是一个明确的操作,从C模块公开一些符号。

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.

当你改变东西时,也要使用重命名重构。