Skip to content

Multidimensional array dimensions not parsed when using variable #72

Open

Description

@Marvin-TMG

I am trying to parse C structs which contain array's defined using variables.

The single dimension arrays are parsed correctly, i.e.
long my1dArray[SOME_VAR];

which returns something like:
'array_size': 'SOME_VAR'

However, for multidimensional arrays the array size is not parsed correctly and returns an empty string:
long my2dArray[SOME_VAR][SOME_VAR];

'array_size':1
'multi_dimensional_array':1
'multi_dimensional_array_size':''

It would be great if array sizes using variable names for multi-dimensional arrays can be supported, since now I need to write a custom parser to retrieve the dimensions myself.

Activity

  1. virtuald commented on Sep 22, 2021

    @virtuald
    Member

    It's likely that cxxheaderparser can handle such constructs, recommend you give that a try as eventually I will abandon this fork in favor of cxxheaderparser.

    Alternatively, happy to accept a fix for this. If I recall correctly, CppHeaderParser's multi-dimensional array support was indeed quite terrible, so this doesn't surprise me at all.

  2. Marvin-TMG commented on Sep 22, 2021

    @Marvin-TMG
    Author
  3. auscompgeek commented on Sep 23, 2021

    @auscompgeek
    Member

    Are these "variables" actually #defines? If so, note from the readme:

    CppHeaderParser only does some very minimal interpretation of preprocessor directives -- and we're looking at removing some of that from this library. If you need anything complex, you should preprocess the code yourself. You can use the excellent pure python preprocessor pcpp, or the preprocessing facilities provided by your favorite compiler.

    We don't implement macros in cxxheaderparser either.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions