使用 CVS #ifdef 我的更改

发布于 2024-08-12 11:14:46 字数 448 浏览 2 评论 0原文

我有一个大型项目,有许多更改尚未签入。我想签入它们,但只有当某个符号被 #define'd 时它们才会生效

CVS 确实能够使用 - 插入 #ifdef 来格式化差异-ifdef 参数。但是,这不会将 #ifdef 合并回我的工作文件中。更糟糕的是,输出包含一些需要删除的丑陋的标头内容。

Index: path/to/my/file.h,v
===================================================================
RCS file: /path/to/my/file.h,v
retrieving revision 1.17
diff --ifdef=TEST -r1.17 file.h

有没有人有一个脚本可以自动执行 CVS diff、删除标头内容并将结果复制回工作文件的过程?

如果有人可以提供帮助,非常感谢。

I have a large project that has many changes not yet checked in. I want to check them in but have them only take effect when a certain symbol is #define'd

CVS does have the ability to format diffs with #ifdef's inserted using the --ifdef argument. However, this does not merge the #ifdef's back into my working file. Even worse, the output includes some ugly header stuff that would need to be removed.

Index: path/to/my/file.h,v
===================================================================
RCS file: /path/to/my/file.h,v
retrieving revision 1.17
diff --ifdef=TEST -r1.17 file.h

Does anyone have a script that would automate the process of doing the CVS diff, removing the header stuff and copying the result back over the working file?

Great thanks if anyone can help.

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

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

发布评论

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

评论(1

絕版丫頭 2024-08-19 11:14:46

我不确定我明白你想要做什么,所以我会回答一个稍微修改过的问题,以防它使你当前的问题过时。

一般来说,#ifdef 仅在编译时设置时才启用。即使它们被签出或签入,除非编译时符号可用,否则宏内的代码也不会被包含。例如:

#ifdef DEBUG
cerr << "Some debug statement" << endl;
#endif

除非您在代码中的其他位置设置了 -DDEBUG 选项(在 GCC 中,请参阅编译器的文档)或 #define DEBUG 1(可用于 #ifdef),上面的调试语句不会被编译到生成的二进制文件中。

话虽这么说,大量使用 #ifdef 很快就会成为维护黑洞,并使代码更难以移植。我建议不要采取这样的策略。

I'm not sure I understand what you are wanting to do, so I will answer a slightly modified question in case it makes your current problem obsolete.

Generally, #ifdef are only enabled if set at compile time. Even if they are checked out or checked in, the code within the macro will not be included unless a compile time symbol is available. For example:

#ifdef DEBUG
cerr << "Some debug statement" << endl;
#endif

Unless you set a -DDEBUG option (in GCC, see your compiler's documenation) or #define DEBUG 1 somewhere else in your code (that is available to the #ifdef), the debug statement above will not be compiled into the resulting binary.

That being said, heavy use of #ifdef can quickly become a maintanence blackhole and make it more difficult for your code to be portable. I would recommend against such a strategy.

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