-
Notifications
You must be signed in to change notification settings - Fork 68
ffigen generating Pointer<Int>
instead of Array<...>
#438
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
Comments
Thanks for the report @tvolkert!
@mannprerak2 Any chance you could take a look? |
Sure I'll take a look today. |
Looks like a case of missing headers. I could replicate the same behaviour when the constant for array length is not defined, libclang corrects it to just a pointer. @tvolkert ffigen should be printing out some logs with SEVERE prefix, you should look into those. You can use compiler opts to pass the include header directory (See compiler-opts in ffigen readme) |
Thanks @mannprerak2! 🙏 This is not the first time users are ignoring |
I agree, perhaps we can refuse to generate the file initially, then prompt user to fix the errors or pass in a flag such as Or a slightly non breaking way would be just the last log informing that the generated file might contain some invalid bindings. |
Users are just going to ignore it again. We should force users to fix the errors or to manually ignore them with a flag.
👍 @tvolkert Can you confirm that adding the right include paths solves your issue? |
Yep, confirmed that adding a And yes, I agree that we should fail to generate the bindings if there's an error - people are just going to ignore stdout messages (especially when they're so verbose) |
Tracking refusing to generate in https://github.com/dart-lang/ffigen/issues/640. |
https://github.com/libexif/libexif/blob/master/libexif/exif-data.h#L47 contains the following struct:
When you run it through
ffigen
, it generates the following binding code:I found it weird that
ExifContent *ifd[EXIF_IFD_COUNT]
translated toexternal ffi.Pointer<ffi.Int> ifd
, and it made it hard to get at the element I wanted... I tried the following:... but the program crashed whenever I tried to use that
nativeContent
pointer.So I then tried to write a simple C library that distilled this into a case I could study more. Here is that code:
I then ran that through
ffigen
, figuring that theTestContent *ifd[IFD_COUNT]
would again turn intoexternal ffi.Pointer<ffi.Int> ifd
.... but it didn't. It instead generated the following binding code:So on the one hand, this generated code makes much more sense! But on the other hand, why didn't it do this for the
libexif
code??The text was updated successfully, but these errors were encountered: