Skip to content

Support handling #define guard #125

Open
@andkae

Description

@andkae

Hello Together,

at the moment i try to parse a file with an #define guard:

from dissect.cstruct import cstruct

cdef = """
/* Define Guard */
#ifndef __MYGUARD
#define __MYGUARD

typedef struct myStruct
{
    char        charVal[16];
}

#endif // __MYGUARD
"""
cs = cstruct()
cs.load(cdef)

This leads to the error unexpected token <Token.IDENTIFIER value='ifndef':

    cs.load(cdef)
  File "/home/ubuntu/.local/lib/python3.9/site-packages/dissect/cstruct/cstruct.py", line 264, in load
    TokenParser(self, **kwargs).parse(definition)
  File "/home/ubuntu/.local/lib/python3.9/site-packages/dissect/cstruct/parser.py", line 386, in parse
    raise ParserError(f"line {self._lineno(token)}: unexpected token {token!r}")
dissect.cstruct.exceptions.ParserError: line 3: unexpected token <Token.IDENTIFIER value='ifndef'>

How can i handle such a message?

Thanks for your support.

BR,
Andreas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions