Python Pcpp预处理器API如何使用?

Python Pcpp预处理器API如何使用?,python,python-3.x,c-preprocessor,Python,Python 3.x,C Preprocessor,我有一个C头文件,需要在构建时解析它以进行一些检查。所以我现在正在尝试使用它。我没有找到任何关于如何使用API的例子,除了。参考资料似乎不再有效了。我尝试了以下方法: #!/usr/bin/python3.7 import sys import pcpp def check_directive(directive): #do the checking #... class Checker(pcpp.Preprocessor): def on_directive_han

我有一个C头文件,需要在构建时解析它以进行一些检查。所以我现在正在尝试使用它。我没有找到任何关于如何使用API的例子,除了。参考资料似乎不再有效了。我尝试了以下方法:

#!/usr/bin/python3.7
import sys
import pcpp

def check_directive(directive):
    #do the checking
    #...

class Checker(pcpp.Preprocessor):
    def on_directive_handle(self, directive, toks, ifpassthru, precedingtoks):
        print("Checking directive...")
        check_directive(directive)
        super(pcpp.Preprocessor, on_directive_handle)


if __name__ == "__main__":
    c_header_path = sys.argv[1]
    with open(c_header_path) as fd:
        c_header = fd.read()

    checker = Checker()
    checker.parsegen(c_header)
但未进行检查,且未产生诊断输出
检查指令…

有人能提供一个使用API的工作示例吗?或者可能会建议另一个python模块执行此类任务