Skip to content

add support for const pointer array const char* arr[] #138

@andkae

Description

@andkae

Hello Together,

the dissect.cstruct is a real big deal to parse c files. For const *char i encounter the error, that const is unsupported. Following example:

from dissect.cstruct import cstruct
cdef = """
const char* pArrChr[] = {
    "myStr1",   /**< comment */
    "myStr2",   /**< comment */
    "myStr3"
};
"""
cs = cstruct()
cs.load(cdef)

Following output:

  File "/home/ubuntu/Desktop/dissect.cstruct/dissect/cstruct/cstruct.py", line 268, in load
    TokenParser(self, \*\*kwargs).parse(definition)
  File "/home/ubuntu/Desktop/dissect.cstruct/dissect/cstruct/parser.py", line 470, in parse
    raise ParserError(f"line {self._lineno(token)}: unexpected token {token!r}")
dissect.cstruct.exceptions.ParserError: line 2: unexpected token <Token.IDENTIFIER value='const'>

Thanks again for your support.

BR,
Andreas

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions