开发者

Using CVS to #ifdef my changes

开发者 https://www.devze.com 2022-12-12 16:16 出处:网络
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

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 h开发者_如何学Pythonave 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消