gtk-rs / gir

Tool to generate rust bindings and user API for glib-based libraries
https://gtk-rs.org/gir/book/
MIT License
230 stars 102 forks source link

Need help: gir-generated tests fail? #1587

Open zaaarf opened 2 months ago

zaaarf commented 2 months ago

I've tried several times, from scratch, but it still seems to fail.

I'm trying to generate the FFI library for libinsane. The result builds, but the tests pretty much all fail. A few examples from the error logs:

tests/layout.c:11:51: error: ‘LibinsaneApi’ undeclared (first use in this function)
   11 |     printf("%s;%zu;%zu\n", "LibinsaneApi", sizeof(LibinsaneApi), alignof(LibinsaneApi));
      |                                                   ^~~~~~~~~~~~
tests/constant.c: In function ‘main’:
tests/layout.c:19:57: error: ‘LibinsaneImgFormat’ undeclared (first use in this function)
   19 |     printf("%s;%zu;%zu\n", "LibinsaneImgFormat", sizeof(LibinsaneImgFormat), alignof(LibinsaneImgFormat));
      |                                                         ^~~~~~~~~~~~~~~~~~
tests/constant.c:32:21: error: ‘guint’ undeclared (first use in this function); did you mean ‘int’?
   32 |     PRINT_CONSTANT((guint) LIBINSANE_CAPABILITY_AUTOMATIC);
      |                     ^~~~~
tests/constant.c:11:22: note: in definition of macro ‘PRINT_CONSTANT’
   11 |     printf(_Generic((CONSTANT_NAME), \
      |                      ^~~~~~~~~~~~~
tests/constant.c:32:21: note: each undeclared identifier is reported only once for each function it appears in
   32 |     PRINT_CONSTANT((guint) LIBINSANE_CAPABILITY_AUTOMATIC);
      |                     ^~~~~
tests/constant.c:11:22: note: in definition of macro ‘PRINT_CONSTANT’
   11 |     printf(_Generic((CONSTANT_NAME), \
      |                      ^~~~~~~~~~~~~
tests/constant.c:32:28: error: expected ‘)’ before ‘LIBINSANE_CAPABILITY_AUTOMATIC’
   32 |     PRINT_CONSTANT((guint) LIBINSANE_CAPABILITY_AUTOMATIC);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have built and installed the library succesfully (if ld can find it, why shouldn't gir?). I've had to edit the gir file to fix a couple minor issues, but nothing that should cause this sort of disruption.

Any idea on what could be causing this, or at least on where I could begin looking?

If it helps, I'm attaching my edited gir file. Everything else is pretty much a 1:1 of what the book does.