Re: [Vala] Extended floating types







 
      From: Ben Iofel <iofelben gmail com>
 Sent: Tuesday, 24 May 2016, 16:20
 Subject: Re: [Vala] Extended floating types
   
error: structs cannot be empty: float128_t


I assumed you were going to put the definition in a VAPI file.If you are doing it from a program you need to 
use the extern keyword:
[SimpleType]
[CCode(cname="float128_t", cheader_filename="softfloat.h", has_type_id = false, default_value = "0")]
public extern struct float128_t {}

void main() {
    float128_t example = (float128_t)1.23;
}

You will find a problem converting the constant to be a float128_t.Not sure how to handle that. 
Also I haven't looked in to which library provides float128_t so the 
header probably won't be correct.
Al



On Tue, May 24, 2016 at 11:16 AM Al Thomas <astavale yahoo co uk> wrote:




 
      From: ben <iofelben gmail com>
 Sent: Tuesday, 24 May 2016, 16:01
 Subject: Re: [Vala] Extended floating types
 

 
This does not work. The C code has: typedef float float128_t;




Try:
[SimpleType][CCode(has_type_id = false, default_value = "0")]public struct float128_t {}
The SimplyType makes it be passed by value rather than by reference when usedas an argument in a function 
call.I think the FloatingType, IntegerType, etc. does casting. As there is norank 12 it just casts to the 
default, i.e. float.

On the subject of binding exotic types. Bindings for C decimal typeswould be useful for financial data and 
transactions.



On Mon, 2016-05-23 at 21:26 -0500, Guillaume Poirier-Morency wrote:
It's possible to declare these types if you need to use them.

https://wiki.gnome.org/Projects/Vala/Manual/Attributes#FloatingType_A
tt
ribute

    [CCode (has_type_id = false)]
    [FloatingType (decimal = false, rank = 12, width = 128]
    struct float128_t {}


   
 


   


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