Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for f32/f64. #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

waywardmonkeys
Copy link

bindgen outputs f32/f64 instead of c_float/c_double now, so let's
support that here.

bindgen outputs f32/f64 instead of c_float/c_double now, so let's
support that here.
@gnzlbg
Copy link
Owner

gnzlbg commented May 28, 2019

Why does bindgen do that? If the platform does not define __STDC_IEC_559__ then f32 and f64 do not necessarily map to C's float and double. musl is an example of such a platform.

@gnzlbg
Copy link
Owner

gnzlbg commented May 28, 2019

That is, whether f32 and f64 are FFI safe is target-dependent.

@gnzlbg
Copy link
Owner

gnzlbg commented May 28, 2019

cc @emilio: rust-bindgen should be generating libc::c_float and libc::c_double here. OTOH, it should not be generating libc::uint32_t and similar types for integers, but u32 instead. It is guaranteed that u32 matches C's uint32_t (https://rust-lang.github.io/unsafe-code-guidelines/layout/scalars.html#fixed-width-integer-types), and therefore the aliases should probably be deprecated from libc.

@emilio
Copy link

emilio commented May 28, 2019

Yes, I think this is a bindgen bug. Should be trivial to patch, probably goes as far as bindgen goes, since even before my rewrite it was generating f32: rust-lang/rust-bindgen@cfdf15f#diff-9fd798837900e68cf440b740d0b7363bL2004

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants