rust-lang / rust-lang/rust-bindgen
--wrap-static-fns prints float complex instead of float _Complex
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Input C/C++ Header
static int take(float _Complex a, int t) { return (int)__real__(a) + t; }
Bindgen Invocation
$ bindgen input.h --wrap-static-fns --wrap-static-fns-path wrap -- -x c -std=gnu11
Actual Results
bindgen exits 0. The wrapper is:
#include "input.h"
int take__extern(float complex a, int t) { return take(a, t); }
complex is a <complex.h> macro, not a C11 keyword. The header does not include that. clang parses float complex a as a parameter named complex of type float:
wrap.c:5:32: error: expected ')'
int take__extern(float complex a, int t) { return take(a, t); }
^
codegen/serialize.rs writes "float complex" for TypeKind::Complex. The C11 spelling is _Complex / float _Complex.
This is not #3255 (by-value _Complex ABI) or #3468 (integer _Complex panic).
Expected Results
Print float _Complex (or include <complex.h> if you really want float complex) so the wrapper is valid C.
Environment
bindgen: 0.73.1 (rust-lang/rust-bindgen 77cbc723)
clang/libclang: Homebrew clang 21.1.8
rustc: 1.97.1
target: aarch64-apple-darwin
OS: macOS
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in codegen/serialize.rs, where TypeKind::Complex is serialized, and reproduce the issue with the bindgen invocation shown. Update the C spelling so the generated wrapper uses valid _Complex syntax, then verify that the wrapper compiles without requiring complex.h.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 80/100