Closed faveoled closed 1 year ago
Hi @faveoled!
First of all, could you try with the latest version? sbt devPublish
will publish bindgen locally, and output the version to use in plugins.sbt
.
I'm not confident it will solve it, but worth a try.
Apart from that - I could use your help reproducing it.
I have a Linux machine (ubuntu-based), but I need to know:
If I can reproduce I can attempt to solve it - my own attempts at building GTK (and surrounding) bindings have been abysmal because of similar issues, and I'd love to figure out common cause.
sudo apt install libgdk-pixbuf-2.0-dev libglib2.0-dev libnotify-dev
user@hp-laptop:~$ dpkg -S /usr/include/libnotify/notification.h
libnotify-dev:amd64: /usr/include/libnotify/notification.h
bindgenBindings := Seq(
Binding(
/* 1 */ (new File("/usr")) / "include" / "libnotify" / "notification.h",
/* 2 */ "libnotify",
/* 3 */ cImports = List("glib.h", "string.h", "simple.h"),
clangFlags = List(
"-I/usr/include/glib-2.0",
"-I/usr/lib/x86_64-linux-gnu/glib-2.0/include/",
"-I/usr/include/gdk-pixbuf-2.0",
)
)
)
Maybe I'll try devPublish
if I have time
Reproduced on HEAD and also found the root cause, but the fix doesn't seem to be trivial.
The minimisation:
typedef struct {
// looks similar but is rendered correctly
union {
long test;
char* help;
} yo;
// cause of the issue
union {
long test;
char* help;
} data[2];
} StructWithUnionArray;
the yo
field will render successfully, the data[2]
will not.
The issue is that the AST at this particular location in the source file doesn't define the anonymous union first and then define the field - instead all you get is a ConstantArray type and nothing else.
Clear, thanks
Well actually, I fixed it in minutes :D Just going to run a few examples and open a PR
I linked a PR that fixes this particular issue and the one you reported before (thanks for those!) PR also contains a fully rendered libnotify binding - but it still won't compile
Unfortunately, we're now hitting a crash in the compiler itself, which I've known about before. It's present in this particular situation because libnotify brings in transitively lots of types from glib (which is gigantic) and the binding i just huge.
Once that PR is merged I will close this particular issue, and open a new one to figure out how to avoid crashing the compiler
Ok. I guess my IDE will crash as well on such big files
I'm getting the error below when trying to generate bindings for
libnotify
. Don't know if it's a bug and can't determine the cause easily.