On Tue, Dec 1, 2009 at 12:59 AM, Jan-Jaap van der Geer
<[email protected]> 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
> [email protected]
> http://mail.gnome.org/mailman/listinfo/vala-list
>
_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list