有谁知道可以分析 C++ 代码库并显示哪些文件包含哪些头文件并突出显示冗余包含的图形表示的工具?我使用过 Understand C++,但它很昂贵,而且在大型(且封装不佳的)代码库上很快变得非常笨重。
最佳答案
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 '...!' .
然后:
- 'sed' 或 'awk' 删除前导 '...'。
- '排序使相同的名字相邻。
- 'uniq -c' 来计算名字。
- 'grep -v' 删除单例。
如:
% g++ -H foo.C |& awk '{print $2}' | sort | uniq -c | grep -v ' 1 '
或者这对你来说太 linux'y/unix'y 了吗?
(windows下,总有cygwin。)
关于c++ - 查看包含依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/426860/