Skip to content

Add validation for array expressions #163

Description

@Miauwkeru

In the case of the cstruct below DATA_LEN is a string called LENGTH. This makes it that char foo[DATA_LEN]; creates a type of <class 'types.char[DATA_LEN]'> which is unexpected as I would expect it to fail if it uses a string as a length specifier or if the expression doesn't resolve to an int.

c_def = """
#define DATA_LEN LENGTH
struct data {
    char foo[DATA_LEN];
};
"""
c_test = cstruct().load(c_def)

So is it an idea to be a bit stricter when parsing the cstruct so this cannot happen?
For example, in the case a #define ... was forgotten it would cause some unexpected behavior.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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