dtolnay / cxx

Safe interop between Rust and C++
https://cxx.rs
Apache License 2.0
5.68k stars 320 forks source link

`f64` field inside a shared struct gets mapped to `float` instead of `double` #1315

Closed klochowicz closed 4 months ago

klochowicz commented 4 months ago

Hi!

I've declared a simple shared struct that has two members:

Data {
   number_float : f32, 
   number_double: f64,
}

I expected the snippet above to generate numbers of types float and double respectively. Unfortunately, the C++ generated code maps both of the fields to float,

Note: Browsing through issues history, I found this https://github.com/dtolnay/cxx/issues/63 (which planned the same mapping as I expected to achieve). I couldn't find anything about it in the documentation though.

klochowicz commented 4 months ago

oops, this turned out to be a human error; had a stale build output from when I initially defined both variables as f32 and that's why my C++ application was failing 🙈

during debugging I added a tiny test that confirms that cxx shares floats and doubles properly, which I'll put up shortly as a PR.

Closing as invalid.