在我的 C++ 文件中,我有
#ifdef DEBUG
then blah
#else
blooh.
我想去掉所有在预处理后没有被编译的文本,这样如果 DEBUG
没有定义,那么所有形式的语句:
#ifdef DBUG
/* some debug code */
#endif
从源代码中删除。
编辑:这是一个例子:
#include <iostream>
//#define DEBUG
int main(){
#ifdef DEBUG
cout << "In debug\n";
#endif
cout << "hello\n";
return 0;
}
运行脚本后,输出应该是
#include <iostream>
//#define DEBUG
int main(){
cout << "hello\n";
return 0;
}
最佳答案
仅仅运行预处理器还不够好吗?例如 g++ -E
?
关于c++ - 在 C++ 中删除编译源的任何脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7716869/