有什么工具可以在上层建筑下重构 c 结构吗?
有没有任何工具可以帮助管理普通的旧 C 结构?
我有许多结构,我想在一个大的快乐结构下重构它们。
也就是说,我目前有:
typedef struct foo_s
{
//variables
}foo_t;
typedef struct bar_s
{
//variables
}bar_t;
static foo_t foo;
static bar_t bar;
我想使用以下内容:
typedef struct super_s
{
foo_t foo;
bar_t bar;
}super_t;
static super_t super;
现在,将“foo”全局替换为“super.foo”,将“bar”替换为“super.bar”有效,但我必须密切注意任何命名陷阱。
还有更专业的吗?
环境:通常,我在 Linux 下使用面向 C/C++ 开发人员的 Eclipse IDE,但 Linux 或 Windows 下的任何工具/插件/脚本/诸如此类的东西都很棒。
Are there any tools which help manage plain old c structures?
I have a number of structures that I would like to refactor under one big happy structure.
That is, I currently have:
typedef struct foo_s
{
//variables
}foo_t;
typedef struct bar_s
{
//variables
}bar_t;
static foo_t foo;
static bar_t bar;
I would like to use the following:
typedef struct super_s
{
foo_t foo;
bar_t bar;
}super_t;
static super_t super;
Now, global replace of "foo" with "super.foo" and "bar" with "super.bar" works, but I have to pay close attention for any naming gotchas.
Is there anything more specialized?
Enviroment: Usually, I work with Eclipse IDE for C/C++ Developers under Linux, but any tool/plugin/script/whatnot under Linux or Windows would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 MSVC(甚至是免费的快速版本)中,您可以搜索特定标记的所有代码引用,这应该可以帮助您至少更准确地找到使用结构/变量/函数的所有位置,在所有位置项目文件。
由于此搜索使用令牌参考图,因此它实际上会过滤掉具有相同变量名称但实际值不同的内容,这已经是一个福音。
[编辑]
我忘记了您必须手动启用此功能,因为它默认设置为使用“原始文本搜索”...
在主菜单中转到:
选项->文本编辑器 -> C/C++->高级->引用
并将禁用解析设置为False。
In MSVC (even the express version, which is free) you can search for all code references of a specific token, this should help you out in at least finding more precisely all places where a struct/variable/function is being used, within all project files.
since this search uses the token reference graph, it will in fact filter out things which have the same variable name but aren't the same actual value, which is already a boon.
[EDIT]
I forgot that you must enable this manually, since its set to using "raw textual search" by default...
in the main menu go to:
Options -> Text Editor -> C/C++ -> Advanced -> References
and set Disable Resolving to False.