Re: [Vala] CCode array length field name
- From: pHilipp Zabel <philipp zabel gmail com>
- To: Jan-Jaap van der Geer <jjvdgeer inbox com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] CCode array length field name
- Date: Tue, 1 Dec 2009 08:21:06 +0100
On Tue, Dec 1, 2009 at 12:59 AM, Jan-Jaap van der Geer
<jjvdgeer inbox com> wrote:
On Mon, 2009-11-30 at 15:09 -0800, Evan Nemerson wrote:
On Mon, 2009-11-30 at 23:45 +0100, pHilipp Zabel wrote:
[CCode (array_length = false)] will make Vala turn errmess.length into
constant -1 instead of errmess_length1. I don't know of any way to
make that constant 252 instead.
IIRC this should do the trick:
[CCode (cname == "os_error")]
public struct error {
public unowned int errnum;
public unowned char errmess[252];
}
Great, this indeed works. The position of the [] in both versions
confuse me, though.
Seconded.
If errmess is null-terminated and utf-8 encoded, you could wrap it as
a weak string.
Why weak?
Because otherwise vala will try to call error_destroy () to have it
free the errmess string:
[CCode (cname = "os_error", cheader_filename = "test.h")]
public struct error {
public int errnum;
public string errmess;
}
int main (string[] args) {
error E;
return 0;
}
-->
gint _main (char** args, int args_length1) {
gint result;
os_error E = {0};
result = 0;
error_destroy (&E);
return result;
}
I agree, binding it as a string is likely the right way to go.
The string not necessarily 0-terminated (although the vast majority will
be) and latin1 encoded (though the vast majority will be ASCII only).
Thanks for your help.
Cheers,
Jan-Jaap
_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]