I'm using Vala to create a Linux app.
To parse JSON, I want to use C, because Vala library is complicated for me and, and it is able to run C functions. The function should return an array of strings that will be used inside Vala code.
The main problem is that unlike Vala, C does not really know what is an array of strings is. I found that the array of strings can be declared as a char*[].
I tried to:
- Use a returned
char*[]as an array of strings in Vala, but that did not help. - Convert returned
char* []from C to a string array in Vala directly, but I was given a lot of compilation errors.
I've made an assumption that char*[] in C, and char*[] in Vala, work differently.
It depends on the what you want do; Vala is actually quite flexible in how it binds to C APIs since it was designed to be used with C APIs which don't know anything about Vala.
My suggestion would be to write the API you want in Vala, then use
valac -C foo.valato transpile the Vala to C code, where you can easily see the API it expects. Basically, though, for a Vala API likestring[] foo(), the expected C signature would be something likegchar** foo(gint* array_length).