Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multidimensional array dimensions not parsed when using variable #72

Open
Marvin-TMG opened this issue Sep 22, 2021 · 3 comments
Open

Comments

@Marvin-TMG
Copy link

Marvin-TMG commented Sep 22, 2021

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.

@virtuald
Copy link
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.

@Marvin-TMG
Copy link
Author

Marvin-TMG commented Sep 22, 2021 via email

@auscompgeek
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants