c++ - 是否有#ifdef 剥离 C/C++ 实用程序

标签 c++ c c-preprocessor conditional-compilation

<分区>

是否有一个实用程序可以删除 #ifdef PRO_VERSION ... #endif 代码?

请不要告诉我有关 Visual Studio 编译器标志或 XCode 的 View 后处理源的信息。我无法像控制台应用程序那样方便地自动化它。

我在这里要做的是找到一个现有的实用程序(如果存在)。如果不是……我想我将不得不重新发明轮子。

最佳答案

unifdef可能正是您要找的。

来自 its manual :

The unifdef utility acts on #if, #ifdef, #ifndef, #elif, #else, and #endif lines. A directive is only processed if the symbols specified on the command line are sufficient to allow unifdef to get a definite value for its control expression. If the result is false, the directive and the following lines under its control are removed. If the result is true, only the directive is removed. An #ifdef or #ifndef directive is passed through unchanged if its controlling symbol is not specified on the command line. Any #if or #elif control expression that has an unknown value or that unifdef cannot parse is passed through unchanged.

关于c++ - 是否有#ifdef 剥离 C/C++ 实用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15893710/

相关文章:

c - 如何在 linux 内核中隐藏/取消隐藏 'ls -a' 的文件?

c - MPI:使用 MPI_Isend 发送消息并使用 C 中的 MPI_Irecv 接收消息

c++ - 在编译时创建一个包含行号的标识符

c - 以总和作为参数的预处理器操作

c++ - 在 C++ 中定义短函数名称别名的最安全方法是什么?

打印二维数组后 C++ 崩溃

c++ - PostMessage 不点击按钮

c++ - 应重绘 Bspline,而不删除窗口的所有其余部分

c++ - Qt 4.6 和 OpenGL : how to capture keyboard presses with three different widgets at once?

c - 在名字列表后写C函数参数类型,有些参数没有类型