cl-bindgen icon indicating copy to clipboard operation
cl-bindgen copied to clipboard

Seems to have trouble with stdint.h types

Open SuperDisk opened this issue 1 year ago • 3 comments

Here's a simple header:

#include <stdint.h>

void somefunc(int8_t x);

cl-bindgen produces an error while processing it:

WARNING: errors occured while parsing somec.c
This may cause bindings to be generated incorrectly.
somec.c:3:15: error: unknown type name 'int8_t'

;; next section imported from file somec.c

(cffi:defcfun "somefunc" :void
  (x :int))

I didn't do any digging as to why it doesn't work, but it seems like c2ffi can correctly process it. Any tips?

SuperDisk avatar Jun 07 '24 15:06 SuperDisk

Unfortunately, this is working on my machine; see the tests I added in 49593966f14d0bd858ed1b8be1f727160aace80c. I need more information to know what's going wrong, but it's probably one of these two things:

  1. You are using an old version of of clang that doesn't use a C language standard that has the standard types available by default. You can provide command line arguments to get the right standard version.
  2. clang isn't giving you its system include directories correctly. See https://github.com/sdilts/cl-bindgen/blob/b90b9ecac881c1d171f2bb5409738f2749874e48/cl_bindgen/util.py#L207C5-L207C18 for hints on how to fix it. If this really is the case, I'll re-open this issue.

Did you need to use the -f option to get this to work? That indicates that it is probably the second issue, but if you find that it's something else, let me know.

sdilts avatar Jan 19 '25 00:01 sdilts

Huh, it's failing the runner that I just added. I wonder what's different about my environment?

sdilts avatar Jan 19 '25 18:01 sdilts

Hi @SuperDisk, I found the problem; it has do do with a mismatch between the system's default clang executable version and the version of libclang that the app is using. edb8480e7d47f9b6954087aa7a70ad47adcd030b should have fixed the issue everywhere; it did for the CI pipeline.

Can you give it another try with the current master branch and see if it works for you?

sdilts avatar Jan 19 '25 19:01 sdilts

Closing due to lack of response, as this should now be working.

sdilts avatar Jun 26 '25 02:06 sdilts