标准 cscope 搜索“查找文件 #include this file”
仅返回 foo.h 直接包含在 bar.c 中的匹配项
但我对所有直接或间接的文件感兴趣
(例如,包含包含 foo.h 的头文件) include foo.h
如果您使用的是 GCC,请cpp -H
在所有模块和grep
您想要的标头上运行:
header=foo.h
# *.c or all interesting modules
for i in *.c; do
# there's bound to be a cleaner regex for this
cpp -H "$i" 2>&1 >/dev/null | grep -q "^\.* .*/$header" && echo "$i"
done
Run Code Online (Sandbox Code Playgroud)