I'm trying to write a VAPI file to use libui (https://github.com/andlabs/libui) in Vala. This is my first try:
[CCode (cheader_filename = "ui.h")]
namespace LibUi {
[CCode (cname = "uiInitOptions", cprefix = "ui", has_type_id = false)]
public struct uiInitOptions {
size_t Size;
}
[CCode (cname = "uiInit", has_type_id = false)]
public char uiInit(uiInitOptions options);
[CCode (cname = "uiMain", has_type_id = false)]
public void uiMain();
[CCode (cname = "uiQuit", has_type_id = false)]
public void uiQuit();
}
And this is a test code in vala:
using LibUi;
public static int main (string[] args) {
uiInitOptions o = uiInitOptions();
uiInit(o);
return 0;
}
Compiling with "valac --vapidir . --pkg libui main.vala"
brings this error:
main.vala.c:(.text+0x3c): undefined reference to `uiInit'
In the example C code of libui is this:
int main(void)
{
uiInitOptions o;
const char *err;
memset(&o, 0, sizeof (uiInitOptions));
err = uiInit(&o);
...
}
How do i make this memset stuff in vala or build it into the vapi file?