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

libclang returns type "int" instead of "int32_t" #54

Open
nightlark opened this issue Feb 18, 2024 · 4 comments
Open

libclang returns type "int" instead of "int32_t" #54

nightlark opened this issue Feb 18, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@nightlark
Copy link
Member

nightlark commented Feb 18, 2024

libclang is returning a type of "int" (or "Int" depending on the function/attribute used), instead of what it had been returning before -- "int32_t" or "int64_t". It is also adding typedefs for each enum, which wasn't happening before.

This may be a macOS specific bug with libclang (the Python bindings?); a Google search turned up a similar issue with Ubuntu where size_t was getting reported by libclang as being of type int.

Note: running clang -Xclang --ast-dump=json -fsyntax-only <header_file> prints the expected type names, but is extremely verbose and includes information on included header files (C/C++ standard library)... it may be worth looking into alternatives to libclang, maybe some that are a bit more user friendly. Python options are likely the easiest/most direct to port, but other languages would also be fine if the available library is easy enough to use (whatever underpins rust bindgen and similar tooling).

@nightlark nightlark added the bug Something isn't working label Feb 18, 2024
@nightlark
Copy link
Member Author

This appears to be macOS specific behavior -- a CI workflow run on Ubuntu (using HELICS 3.5.0 headers) gave the expected types.
helics.ast.json
helics.types.json

@nightlark
Copy link
Member Author

Some alternatives to libclang for parsing C/C++ code and getting an AST that have come up recently:

@afisher1
Copy link
Member

This behavior would definitely break our conversion code across the board if we were trying to generate bindings on macOS. Is this specific to the latest version of libclang? Clang 14 is what I have been using for matlab and octave binding generation. We might need to lock down clang to a specific version as a stop gap in our other binding generator repos.

@nightlark
Copy link
Member Author

nightlark commented Feb 21, 2024

I noticed it with clang 16 — I haven’t tried older versions of clang (or newer), but it seems like the kind of issue that could affect most versions.

As part of releases we could automate the header to json part of binding generation in a CI job, which would guarantee that the bindings are done on an OS where libclang gives the correct types (…maybe).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants