问题描述
我想知道是否可能,如果是的话,我可以在
C ++源文件上运行一个 C 预处理器,如cpp,只处理条件指令#if #endif等。我想要其他
指令保持完整的输出文件。
I was wondering if it is possible, and if yes how, can I run a C preprocessor, like cpp, on aC++ source file and only process the conditional directives #if #endif etc. I would like otherdirectives to stay intact in the output file.
我对C#代码做一些分析,没有C#预处理器。我的想法是在C#文件上运行 C 预处理器,并仅处理条件。例如,#region指令将在文件中保留
,但是cpp似乎删除了#region。
I'm doing some analysis on C# code and there is no C# pre-processor. My idea is to run a C preprocessor on C# file and process only conditionals. This way for example, the #region directive, will stayin the file, but cpp appears to remove #region.
推荐答案
您可能正在寻找类似的工具:
You might be looking for a tool like coan:
设计为处理 #if
和 #ifdef
预处理器行,并相应地删除代码,但它有很多其他可能使用。
It's precisely designed to process #if
and #ifdef
preprocessor lines, and remove code accordingly, but it has a lot of other possible uses.
这篇关于如何仅对某些(#if /#endif)指令应用C预处理器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!