[Vala] A problem with a vapi file
- From: Luca Dionisi <luca dionisi gmail com>
- To: vala-list gnome org
- Subject: [Vala] A problem with a vapi file
- Date: Fri, 4 Mar 2011 18:15:57 +0100
Hi all
I am in troubles with creating a vapi file in order to use a non-glib
library in a vala application.
I searched but did not find a comprehensive tutorial for doing it.
So I hope that someone in the mailing list could give me some tips.
I created a sort of test-case for my current issue.
We have a library with these sources:
libfoo.c [http://pastebin.com/kDtaCR6Q]
libfoo.h [http://pastebin.com/aDa3VEWt]
We have a simple test application in C with this source
testfoo.c [http://pastebin.com/0At7UTVs]
When linked statically with the libfoo it compiles and run correctly
without errors or warnings.
Now I would like to use the library in vala with an interface like this:
test_foo.vala [http://pastebin.com/qTAP9gqw]
and I tried with the following vapi:
libfoo.vapi [http://pastebin.com/bVnZU4NL]
With this vapi the generated C file is the following:
test_foo.c [http://pastebin.com/Lwu3JR8i]
The difference with the first C file is that the variable that is used
to carry a "Foo" object is of type foo_t*, while it should be a foo_t.
What do I have to change in the vapi file to obtain a mapping more precise?
As a side note, the generated C file compiles and runs ok, but the
compilation has worrying warnings:
$ valac --save-temps -c --pkg libfoo --vapidir . -X -I. test_foo.vala
/tmp/test_foo.c: In function ‘_vala_main’:
/tmp/test_foo.c:20: warning: assignment from incompatible pointer type
/tmp/test_foo.c:21: warning: passing argument 1 of ‘foo_sum’ from
incompatible pointer type
./libfoo.h:4: note: expected ‘foo_t’ but argument is of type ‘struct foo_st **’
/tmp/test_foo.c:22: warning: passing argument 1 of ‘foo_destroy’ from
incompatible pointer type
./libfoo.h:5: note: expected ‘foo_t’ but argument is of type ‘struct foo_st **’
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]