【发布时间】:2009-01-09 02:27:20
【问题描述】:
有没有人知道一种工具可以分析 C++ 代码库并显示哪些文件包含哪些头文件并突出显示冗余包含的图形表示?我使用了理解 C++,但它很昂贵,并且在大型(且封装不佳)代码库上很快变得非常笨拙。
【问题讨论】:
-
Tim 强调的问题重复
标签: c++ code-analysis analysis
有没有人知道一种工具可以分析 C++ 代码库并显示哪些文件包含哪些头文件并突出显示冗余包含的图形表示?我使用了理解 C++,但它很昂贵,并且在大型(且封装不佳)代码库上很快变得非常笨拙。
【问题讨论】:
标签: c++ code-analysis analysis
gcc/g++ 总是有 "-H" 选项...
例如:% g++ -H foo.C
'-H'
Print the name of each header file used, in addition to other
normal activities. Each name is indented to show how deep in the
'#include' stack it is. Precompiled header files are also
printed, even if they are found to be invalid; an invalid
precompiled header file is printed with '...x' and a valid one
with '...!' .
然后:
如:
% g++ -H foo.C |& awk '{print $2}' | sort | uniq -c | grep -v ' 1 '
或者这对你来说太 linux'y / unix'y?
(windows下,总有cygwin。)
【讨论】:
试试这个
Tool to track #include dependencies
自己编写一个听起来也是一个非常简单的练习。添加“冗余”包括决心虽然可能更具挑战性。必须解析并遵循 ifdefs 等。但是对于仅仅创建一个依赖树来说它是非常简单的。
【讨论】: