rust-lang / rust-lang/rust-bindgen

long double becomes u128

Open
#1,549 17 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

Input C/C++ Header
typedef long double foo
Bindgen Invocation
$ bindgen input.h 
Actual Results
/* automatically generated by rust-bindgen */

pub type a = u128;
Expected Results

I'm not entirely sure. Here are the idea's I can think of

  • use f64, but that leeds to it's own set of issues (#1529).
  • use the f128 crate but the layout of the f128 is different to the layout of a c long double
  • add a c_longdouble type to std::os::raw. The problem is that on many machines (including mine) long double is a 16 byte float, which rust doesn't suport
  • Through an error. This will avoid confusion, but also make also will mean losing suport for many .h files
  • use u128. The problem here is were treating a float as an int, and that will mean all sorts of problems

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the shown input.h and bindgen invocation, then read the discussion around the listed expected-result options and issue #1529. Done means the project has an agreed, tested handling for C/C++ long double that avoids silently representing it as u128.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp, rust
Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.