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

ran clang2py on a header that had the "raise" symbol #97

Open
bogen85 opened this issue Jun 28, 2021 · 3 comments
Open

ran clang2py on a header that had the "raise" symbol #97

bogen85 opened this issue Jun 28, 2021 · 3 comments

Comments

@bogen85
Copy link

bogen85 commented Jun 28, 2021

Since that is a python keyword, loading the resulting file is problematic....

I was able to fix and a few other issues with:

sed 's/^raise/#_raise/'
sed "s,^_libraries\['FIXME_STUB'].*,_libraries['FIXME_STUB'] = ctypes.CDLL('libc.so.6'),"
sed 's/^pthread/#pthread/'
@bogen85
Copy link
Author

bogen85 commented Jun 28, 2021

In general clang2py does not like the headers I give it.
I was trying to use cffi on some headers and it did not them either.
The following made them more palatable, and clang2py likes headers resulting from this as well:

result = subprocess.check_output(f"clang -E -I. {header}", shell=True)
sanitized = []
for line in result.decode(encoding='utf-8').split('\n'):
  for bad in ['__asm__', '__attribute__']:
    if bad in line:
      line = f'{line.split(bad)[0]};'.replace(';;',';')
    sanitized.append(line)
lines = "\n".join(sanitized)

With sanitized headers and the above sed commands I'm having a lot more success with ctypeslib than I was having with cffi
I'm passing in my library and getting most symbols resolved by it.
When I try to pass in libc.so.6 as well, I get no output from clang2py, but that is a different issue.

@bogen85
Copy link
Author

bogen85 commented Jun 28, 2021

Well, actually I'm fixing it all up in python now, the sed stuff was just temporary from the command line to get it working.

@mara004
Copy link

mara004 commented Feb 21, 2024

Sounds like clang2py would need a conflicting names resolver?

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

2 participants