【问题标题】:How to get the list of define in c header file?如何获取c头文件中的define列表?
【发布时间】:2019-03-03 23:57:21
【问题描述】:

我想解析并获取c头文件中的定义列表(#define)。

我知道有很多 python 模块,但我找不到像“#if”、“#undef”这样的解析预处理器。

如果头文件如下:

#define ABC
#define DEF
#define CONDITION
#ifdef CONDITION
#undef DEF
#define HIJ
#endif

我想得到如下列表:

ABC, CONDITION, HIJ  // no DEF

你对此有什么想法吗?

【问题讨论】:

标签: python c++ c header


【解决方案1】:

我发现了(但没有使用 python)。

回声 | g++ -dM -E my_header.h |排序 > out.txt

包括我的路径

回声 | g++ -dM -E -I"my_path" my_header.h |排序 > out.txt

【讨论】:

    猜你喜欢
    • 2011-09-28
    • 2023-03-19
    • 1970-01-01
    • 2013-05-18
    • 1970-01-01
    • 2015-03-27
    • 2020-12-06
    • 1970-01-01
    • 2017-06-28
    相关资源
    最近更新 更多