For some reason, a C library I am using (libmpdclient) does not provide a direct free function for a simple struct, named struct mpd_pair
, but a slightly more complex function with a context as parameter.
So, I have to use free_function = ""
for the compact class of that C struct in the vapi file, and use another function manually to actually free the struct.
But this makes Vala 0.56.16 generate wrong C code that fails to compile when using an Array of that struct (aka Mpd.Pair[]
), at “free” time:
browser_artists = (_vala_array_free (browser_artists, browser_artists_length1, (GDestroyNotify) ), NULL);
Where the (GDestroyNotify) cast is missing an arg (which is the free_function arg, and should be NULL in my case).
The error reported is indeed:
error: expected expression before ‘)’ token
Here is the compact class:
[CCode (cname = "struct mpd_pair",
free_function = "")]
[Compact]
public class Pair {
public unowned string name;
public unowned string value;
...
Is it a valac 0.56 bug to not insert the NULL pointer as GDestroyNotify arg ?