--wrap-static-fns emits incomplete struct _bindgen_ty_N for anonymous record parameters
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 67/100
Research direction
Start with codegen/serialize.rs, especially the TypeKind::Comp handling that emits struct or union names, and reproduce the issue with the bindgen command in the report. Check the generated wrapper for anonymous struct and union parameters; done means the wrapper uses a complete type after including input.h while named-record wrapping continues to compile.
Written by the indexing model from the issue text.
Description
Input C/C++ Header
static int take(struct { int x; int y; } s, int t) { return s.x + t; }
Bindgen Invocation
$ bindgen input.h --wrap-static-fns --wrap-static-fns-path wrap -- -x c -std=gnu11
Actual Results
bindgen exits 0. The generated wrapper is:
#include "input.h"
int take__extern(struct _bindgen_ty_1 s, int t) { return take(s, t); }
struct _bindgen_ty_1 is not in the header. clang:
wrap.c:5:25: warning: declaration of 'struct _bindgen_ty_1' will not be visible outside of this function
wrap.c:5:39: error: variable has incomplete type 'struct _bindgen_ty_1'
codegen/serialize.rs prints struct {canonical_name} for TypeKind::Comp. For an anonymous record that name is _bindgen_ty_N. A named struct S { int x; int y; } wrapper prints struct S and compiles.
Same thing for an anonymous union (union _bindgen_ty_1).
This is not #3403 (pointer-to-array declarators) or #2805 (_Bool vs bool).
Expected Results
The wrapper should use a C type that is complete after #include "input.h" (the original anonymous type, or a tag defined in the wrapper).
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
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 846
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 11
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from rust-lang/rust-bindgen
-
--enable-cxx-namespaces panics on namespace [[deprecated]] { ("[" is not a valid Ident)Possibly taken @lwz23 claimed this 47 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
rust-lang/rust-bindgen#3485 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
rust-lang/rust-bindgen#3483 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
rust-lang/rust-bindgen#3370 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
rust-lang/rust-bindgen#3363 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
rust-lang/rust-bindgen#3540 ·
Maintainers usually reply within 1 day
All issues in rust-lang/rust-bindgen
Similar issues
-
good first issue help wanted program
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
hffgzktbcc-blip/ounce-core#297 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
nautechsystems/nautilus_trader#5631 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
bytecodealliance/rustix#1736 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
longbridge/gpui-kit#3871 ·
Maintainers usually reply within 1 day
-
area:models enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day