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

发布于 2024-08-22 16:11:14 字数 159 浏览 3 评论 0原文

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

例如,当我在源文件中实现一个函数时,它是否会自动在头文件中插入正确的行?

我确实看过像lzz这样的解决方案,但它们不是我正在寻找的。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

假装不在乎 2024-08-29 16:11:14

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

说明

  1. 将函数原型添加到.h文件中 void foobar()
  2. 选择函数名称“foobar”(尝试双击)
  3. 在工具栏中单击“Source”->“foobar”实施方法
  4. 向导它

可能是你开箱即用的最好的方法

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

南风起 2024-08-29 16:11:14

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

但是,如果声明/实现已经设置并且您想要修改其中任何一个,我想在 Eclipse 中您可能需要使用 切换函数定义在可能的工作流程中,您可以在剪贴板中复制中间切换结果,然后将其粘贴到更改的声明上或实施声明。

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文