工具/分析器为$ P $#如果pprocessor陈述? [英] Tool/Parser for preprocessor #if statements?

查看:153
本文介绍了工具/分析器为$ P $#如果pprocessor陈述?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作,其中包含许多preprocessor许多C源$ C ​​$ C文件#如果 #elseif 的#else 语句。

I am working on many C-sourcecode files which contain many preprocessor #if, #elseif and #else statements.

这语句经常检查了的#define ,例如

This statements often check for a #define, e.g.

#if(Switch_TestMode == Switch_TestModeON)
/* code 1 */
#else
/*code 2 */
#endif

这通常preprocessor语句都设在C-if语句,这使得源$ C ​​$ C几乎无法读取人类beeings。

Often this preprocessor statements are located within c-if statements which makes the sourcecode nearly unreadable for human beeings.

的#define 使用范围是这个preprocessor ​​#如果语句一个额外的文件中定义。

The #defines used for this preprocessor #if statements are defined within an extra file.

我的想法是现在有一个工具来做这个的#define D开关设置,然后只复制源$ C ​​$ C的使用当前#适用线定义/开关设置。

My idea now is to have a tool which checks this #defined switch settings and then only copies the lines of sourcecode which apply using the current #defines/switch settings.

对于上面的例子,我想获得该只包含一个新的.c文件

For the above example I would like to get a new .c file which contains only

/*code 2 */

假设的#define Switch_TestMode 不等于 Switch_TestModeON

是否有工具(免费||成本低),可里面做这份工作吗?
还是我来写这个我自己的preprocessor解析器?

Are there tools (freeware || low-cost) available which do this job? Or do I have to write my own preprocessor parser for this?

(这是不可能的,我使用的做这件工作的特殊参数运行编译器,因为我们公司是创建C源$ C ​​$ C,另一家公司正在编制)。

(It is impossible for me to run the compiler using a special parameter which does this job, because our company is creating the C-sourcecode, another company is compiling.)

感谢您的任何暗示!

问候

托马斯

推荐答案

尝试 Sunifdef

编辑:现在这已成为科恩

这篇关于工具/分析器为$ P $#如果pprocessor陈述?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆