Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What C type should I use for f64 in my C FFIs?

Tags:

rust

ffi

When I return i32 data from my C FFI functions, I use the datatype int32_t and it works like a charm. What is the equivalent of Rust's f64 datatype in C?

like image 778
The Unfun Cat Avatar asked Oct 27 '25 14:10

The Unfun Cat


1 Answers

Use libc::c_double.

Other direct mappings:

f32 | c_float   
f64 | c_double  
i8  | int8_t    
i16 | int16_t   
i32 | int32_t   
i64 | int64_t   
u8  | uint8_t
u16 | uint16_t  
u32 | uint32_t  
u64 | uint64_t  
like image 122
Shepmaster Avatar answered Oct 30 '25 12:10

Shepmaster



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!