我可以只从带有 Ctags 的C++文件中获取 #includes 吗?

Can I get only the #includes from C++ files with Ctags?

本文关键字:文件 获取 #includes C++ Ctags 我可以      更新时间:2023-10-16

是否可以从具有旺盛的Ctags通用Ctags的指定C++源文件中获取仅 #include + file指令的列表?

使用最新版本的 Universal-ctags,您可以使用以下命令行来枚举头文件:

$ ctags -o - --extras=r --kinds-C++=h --language-force=C++ INPUT-FILE.h

例如:

$./ctags -o - --extras=r --kinds-C++=h --language-force=C++ /usr/include/pwd.h 
bits/types.h    /usr/include/pwd.h  /^#include <bits/types.h>/;"   h
features.h  /usr/include/pwd.h  /^#include <features.h>/;"  h
stddef.h    /usr/include/pwd.h  /^#include <stddef.h>/;"    h
stdio.h /usr/include/pwd.h  /^# include <stdio.h>/;"    h