gpt4 book ai didi

c++ - 如何获取源文件中定义的列表函数

转载 作者:行者123 更新时间:2023-11-30 21:49:09 30 4
gpt4 key购买 nike

例如,我有以下源文件。

#define xyz 50
int global_var = 45;

struct abd
{
type data1;
type1 data2;
type2 data3;
}

int function1(arg1, arg2, arg3)
{

//statements

}

user_defined_type function2 ( arg4,arg5,arg6)
{

//statements

}

void function3 ( argx, argy,argz)
{

//statements

}

如何获得 function1function2function3 的输出。我尝试使用 perl 读取该文件,但无法获取从整个源文件中提取函数的逻辑。

最佳答案

我不会深入分析源代码,因为有太多复杂的 C 语言语法无法涵盖这一点。相反,将其编译为目标文件(gcc-c 选项),然后使用 nm命令获取定义的符号,例如:

$ nm check.o 
0000000000000000 T function1
000000000000000f T function2
000000000000001e T function3
0000000000000000 D global_var

从现在起,您可以使用您想要的任何解析工具提取 T 类型的符号。

"T"
"t" The symbol is in the text (code) section.

关于c++ - 如何获取源文件中定义的列表函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26234147/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com