如何收集C ++头文件中的所有声明 [英] How to collect all declarations in C++ header file

查看:77
本文介绍了如何收集C ++头文件中的所有声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个工具来收集.h文件中的所有声明(类名,函数名,全局变量,宏等)。



for例如,给定文件test.h



//test.h



#define PI 3.1415



int gv = 0;



无效测试()

{< br $>
}



类MyApp

{

};



该工具可以接受并解析文件并输出如下内容:



PI

gv

测试

MyApp



有没有这样的工具来实现这个目标?

I'm seeking a tool to collect all declarations (class name, function name, global variable, macro, etc.) from .h files.

for example, given the file test.h

//test.h

#define PI 3.1415

int gv = 0;

void Test()
{
}

class MyApp
{
};

The tool can accept and parse the file and output something like following:

PI
gv
Test
MyApp

Is there such a tool to achieve this?

推荐答案

使用LLVM的clang预处理器。这会创建一个解析树(不仅仅是符号),您可以从中提取符号名称。



https://github.com/sk-havok/clang-extract [ ^ ]
Use LLVM's clang preprocessor. This creates a parse tree (more than just symbols) from which you can extract symbol names.

https://github.com/sk-havok/clang-extract[^]


这篇关于如何收集C ++头文件中的所有声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆