MatthieuDartiailh / pyclibrary

C parser and ctypes automation for python
http://pyclibrary.readthedocs.org
MIT License
66 stars 29 forks source link

Fail to parse a single enum #58

Open wtdcode opened 3 years ago

wtdcode commented 3 years ago

C file:

typedef enum Test {
    A1L2,

    A = A1L2,

} Test;

Script:

from pyclibrary import CParser
print(CParser(["/tmp/test.h"]).defs)

Get

{'types': {'Test': Type('enum Test A1L2 A A1L2')}, 'variables': {}, 'fnmacros': {}, 'macros': {}, 'structs': {}, 'unions': {}, 'enums': {}, 'functions': {}, 'values': {'A1L2': 0, 'A': None}}
wtdcode commented 3 years ago

When evaluating the value, the 1L in A1L2 is treated as an integer literal and thus rstripped.