Re: [Vala] Vala thinks uint32 constant is int64



On 11/19/2010 10:15 PM, Evan Nemerson wrote:
On Fri, 2010-11-19 at 19:58 +0100, Jaroslav Smid wrote:
Well, U suffix works, but I thought vala would be smart enough to handle
this. Anyway, I had to switch to C because vala doesn't use size_t for array
sizes and uses int.

public void foo ([CCode (array_length_type = "size_t")] int[] bar);

Generally array_length_type is used for bindings... if you just need to
use a C library which uses size_t you can just do something like the
above in your vapi and it will work perfectly. Lots of bindings use this
since the type used for the array length in C is so inconsistent (often
even within the same library).

If you want libraries you write in Vala to expose size_t as the array
length parameter, you can still do it but you will occasionally have to
work around issues caused by Vala thinking the variable is an int
(although it will be generated as size_t). That wouldn't be too
difficult, though... certainly less work than writing everything in C.


pancake: sorry for sending messed up message :-)

On Thu, Nov 18, 2010 at 10:53 PM, pancake<pancake youterm com>  wrote:

Vala should handle this correctly. The type is uint32 and not int32

On 18/11/2010, at 15:31, Xavier Bestel<xavier bestel free fr>  wrote:

Hi,

On Thu, 2010-11-18 at 10:52 +0100, Jaroslav Smid wrote:
/home/jardik/Projects/DAOLinux/ErfEditor/Blowfish.vala:6.15-6.24: error:
Expected initializer of type `uint32' but got `int64'
        0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344,
                    ^^^^^^^^^^

I think it's because this constant is too big to fit a signed int32, so
it's a signed int64 =>  error.
You should suffix it to explicitly tell it's unsigned to make it fit, I
guess.

       Xav

_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list


_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list



Anyway, any chance that vala will switch to size_t (or at least intptr_t or ptrdiff_t (which is standard defined type for pointer difference)) from int for array indexing and array sizes? Writing that stuff before each array is very ugly. At least some command line argument that would force vala to use size_t? I know languages like C# and Java use int - but that is what I don't get. It's much better if type with the size of a pointer is used for it,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]