Re: 如何移除特定的 conditional compilation?
※ 引述《tinlans.bbs@whshs.cs.nccu.edu.tw (汀)》之銘言:
: ※ 引述《roylee.bbs@bbs.cs.nctu.edu.tw (roylee)》之銘言:
: > 最好是用 gcc / cpp 可以直接做到
: gcc -UFOO 直接當成 #undef FOO,
: gcc -DFOO 直接當成 #define FOO。
: > 如果有其他工具也歡迎
: > 謝謝
先謝謝兩位( how & tinlans)回應
我之前描述的不夠清楚,再說明一點
某程式提供許多功能,用 #ifdef 包住
如果我要讀該程式,可以先把一些不重要的功能給濾掉
使程式碼好讀,(不是編譯)
$ cat prog.c
//#include <stdio.h>
#ifdef FOO
void foo(){ }
#endif
#ifdef BAR
void bar(){ }
#endif
int main(){ return 0; }
其中, FOO 為不重要的部份,想加以濾掉,變成
//#include <stdio.h>
#ifdef BAR
void bar(){ }
#endif
int main(){ return 0; }
如果用 preprocessor ,所有的 macro 都被展開了
$ cpp -E -P -DBAR prog.c
void bar(){ }
int main(){ return 0; }
我需要 #ifdef, #endif 都還留著
雖然是個簡單的 filter ( 有 stack)
不還是想知道有沒有好的工具
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.104.37.155
推
04/14 19:57, , 1F
04/14 19:57, 1F
推
04/14 22:09, , 2F
04/14 22:09, 2F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 4 之 4 篇):